Skip to content

Commit f5bb1dc

Browse files
committed
Reinstate migrations for upgrading from 1.x to 2.0
1 parent 2e25603 commit f5bb1dc

File tree

5 files changed

+91
-30
lines changed

5 files changed

+91
-30
lines changed

README.md

-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ Add `django_dbq` to your installed apps
2727

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

30-
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.
31-
32-
```
33-
DROP TABLE django_dbq_job;
34-
DELETE FROM django_migrations WHERE app='django_dbq';
35-
```
36-
37-
Then, run `python manage.py migrate` to recreate the jobs table.
38-
3930
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.
4031

4132
### Describe your job

django_dbq/migrations/0001_initial.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# Generated by Django 3.2rc1 on 2021-04-05 14:31
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
23

3-
from django.db import migrations, models
4+
from django.db import models, migrations
45
import uuid
56

7+
from django.db.models import UUIDField
68

7-
class Migration(migrations.Migration):
89

9-
initial = True
10+
class Migration(migrations.Migration):
1011

1112
dependencies = []
1213

@@ -16,39 +17,38 @@ class Migration(migrations.Migration):
1617
fields=[
1718
(
1819
"id",
19-
models.UUIDField(
20-
default=uuid.uuid4,
20+
UUIDField(
21+
serialize=False,
2122
editable=False,
23+
default=uuid.uuid4,
2224
primary_key=True,
23-
serialize=False,
2425
),
2526
),
26-
("created", models.DateTimeField(auto_now_add=True, db_index=True)),
27+
("created", models.DateTimeField(db_index=True, auto_now_add=True)),
2728
("modified", models.DateTimeField(auto_now=True)),
2829
("name", models.CharField(max_length=100)),
2930
(
3031
"state",
3132
models.CharField(
32-
choices=[
33-
("NEW", "New"),
34-
("READY", "Ready"),
35-
("PROCESSING", "Processing"),
36-
("FAILED", "Failed"),
37-
("COMPLETE", "Complete"),
38-
],
3933
db_index=True,
40-
default="NEW",
4134
max_length=20,
35+
default="NEW",
36+
choices=[
37+
("NEW", "NEW"),
38+
("READY", "READY"),
39+
("PROCESSING", "PROCESSING"),
40+
("FAILED", "FAILED"),
41+
("COMPLETE", "COMPLETE"),
42+
],
4243
),
4344
),
44-
("next_task", models.CharField(blank=True, max_length=100)),
45-
("workspace", models.JSONField(null=True)),
45+
("next_task", models.CharField(max_length=100, blank=True)),
46+
("workspace", models.TextField(null=True)),
4647
(
4748
"queue_name",
48-
models.CharField(db_index=True, default="default", max_length=20),
49+
models.CharField(db_index=True, max_length=20, default="default"),
4950
),
50-
("priority", models.SmallIntegerField(db_index=True, default=0)),
5151
],
52-
options={"ordering": ["-priority", "created"],},
52+
options={"ordering": ["-created"],},
5353
),
5454
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("django_dbq", "0001_initial"),
11+
]
12+
13+
operations = [
14+
migrations.AlterModelOptions(name="job", options={"ordering": ["created"]},),
15+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11 on 2018-07-13 10:00
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
("django_dbq", "0002_auto_20151016_1027"),
12+
]
13+
14+
operations = [
15+
migrations.AlterModelOptions(
16+
name="job", options={"ordering": ["-priority", "created"]},
17+
),
18+
migrations.AddField(
19+
model_name="job",
20+
name="priority",
21+
field=models.SmallIntegerField(db_index=True, default=0),
22+
),
23+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django 3.2rc1 on 2021-08-18 02:47
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("django_dbq", "0003_auto_20180713_1000"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="job",
15+
name="state",
16+
field=models.CharField(
17+
choices=[
18+
("NEW", "New"),
19+
("READY", "Ready"),
20+
("PROCESSING", "Processing"),
21+
("FAILED", "Failed"),
22+
("COMPLETE", "Complete"),
23+
],
24+
db_index=True,
25+
default="NEW",
26+
max_length=20,
27+
),
28+
),
29+
migrations.AlterField(
30+
model_name="job", name="workspace", field=models.JSONField(null=True),
31+
),
32+
]

0 commit comments

Comments
 (0)