Skip to content

Commit

Permalink
Reinstate migrations for upgrading from 1.x to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
j4mie committed Aug 18, 2021
1 parent 2e25603 commit f5bb1dc
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 30 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ Add `django_dbq` to your installed apps

### Upgrading from 1.x to 2.x

This library underwent significant changes in its 2.x release, which meant migrating automatically was not practical. Before upgrading, you should open a database shell and run the following commands. Note that this will **delete all your existing jobs**, so you should ensure all jobs are completed before proceeding, and make sure you don't need any data at all from the jobs table.

```
DROP TABLE django_dbq_job;
DELETE FROM django_migrations WHERE app='django_dbq';
```

Then, run `python manage.py migrate` to recreate the jobs table.

Note that version 2.x only supports Django 3.1 or newer. If you need support for Django 2.2, please stick with the latest 1.x release.

### Describe your job
Expand Down
42 changes: 21 additions & 21 deletions django_dbq/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Generated by Django 3.2rc1 on 2021-04-05 14:31
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
from django.db import models, migrations
import uuid

from django.db.models import UUIDField

class Migration(migrations.Migration):

initial = True
class Migration(migrations.Migration):

dependencies = []

Expand All @@ -16,39 +17,38 @@ class Migration(migrations.Migration):
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
UUIDField(
serialize=False,
editable=False,
default=uuid.uuid4,
primary_key=True,
serialize=False,
),
),
("created", models.DateTimeField(auto_now_add=True, db_index=True)),
("created", models.DateTimeField(db_index=True, auto_now_add=True)),
("modified", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=100)),
(
"state",
models.CharField(
choices=[
("NEW", "New"),
("READY", "Ready"),
("PROCESSING", "Processing"),
("FAILED", "Failed"),
("COMPLETE", "Complete"),
],
db_index=True,
default="NEW",
max_length=20,
default="NEW",
choices=[
("NEW", "NEW"),
("READY", "READY"),
("PROCESSING", "PROCESSING"),
("FAILED", "FAILED"),
("COMPLETE", "COMPLETE"),
],
),
),
("next_task", models.CharField(blank=True, max_length=100)),
("workspace", models.JSONField(null=True)),
("next_task", models.CharField(max_length=100, blank=True)),
("workspace", models.TextField(null=True)),
(
"queue_name",
models.CharField(db_index=True, default="default", max_length=20),
models.CharField(db_index=True, max_length=20, default="default"),
),
("priority", models.SmallIntegerField(db_index=True, default=0)),
],
options={"ordering": ["-priority", "created"],},
options={"ordering": ["-created"],},
),
]
15 changes: 15 additions & 0 deletions django_dbq/migrations/0002_auto_20151016_1027.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
("django_dbq", "0001_initial"),
]

operations = [
migrations.AlterModelOptions(name="job", options={"ordering": ["created"]},),
]
23 changes: 23 additions & 0 deletions django_dbq/migrations/0003_auto_20180713_1000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-07-13 10:00
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("django_dbq", "0002_auto_20151016_1027"),
]

operations = [
migrations.AlterModelOptions(
name="job", options={"ordering": ["-priority", "created"]},
),
migrations.AddField(
model_name="job",
name="priority",
field=models.SmallIntegerField(db_index=True, default=0),
),
]
32 changes: 32 additions & 0 deletions django_dbq/migrations/0004_auto_20210818_0247.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.2rc1 on 2021-08-18 02:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("django_dbq", "0003_auto_20180713_1000"),
]

operations = [
migrations.AlterField(
model_name="job",
name="state",
field=models.CharField(
choices=[
("NEW", "New"),
("READY", "Ready"),
("PROCESSING", "Processing"),
("FAILED", "Failed"),
("COMPLETE", "Complete"),
],
db_index=True,
default="NEW",
max_length=20,
),
),
migrations.AlterField(
model_name="job", name="workspace", field=models.JSONField(null=True),
),
]

0 comments on commit f5bb1dc

Please sign in to comment.