Browse Source

Divide migration file

pull/1619/head
Hironsan 3 years ago
parent
commit
8395f75542
4 changed files with 55 additions and 5 deletions
  1. 5
      backend/api/migrations/0024_auto_20211221_1444.py
  2. 37
      backend/api/migrations/0025_auto_20220107_0158.py
  3. 16
      backend/api/migrations/0026_auto_20220107_0200.py
  4. 2
      backend/api/migrations/0027_auto_20211222_0454.py

5
backend/api/migrations/0024_auto_20211221_1444.py

@ -28,8 +28,5 @@ class Migration(migrations.Migration):
model_name='span',
name='label',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.spantype'),
),
migrations.DeleteModel(
name='Label',
),
)
]

37
backend/api/migrations/0025_auto_20220107_0158.py

@ -0,0 +1,37 @@
# Generated by Django 3.2.8 on 2022-01-07 01:58
from django.db import migrations
def recover_label(apps, schema_editor):
DocType = apps.get_model('api', 'DocType')
SpanType = apps.get_model('api', 'SpanType')
Label = apps.get_model('api', 'Label')
for model in [DocType, SpanType]:
for label in model.objects.all():
old_label = Label(
id=label.id,
text=label.text,
prefix_key=label.prefix_key,
suffix_key=label.suffix_key,
project=label.project,
background_color=label.background_color,
text_color=label.text_color,
created_at=label.created_at,
updated_at=label.updated_at
)
old_label.save()
class Migration(migrations.Migration):
dependencies = [
('api', '0024_auto_20211221_1444'),
]
operations = [
migrations.RunPython(
code=migrations.RunPython.noop,
reverse_code=recover_label
)
]

16
backend/api/migrations/0026_auto_20220107_0200.py

@ -0,0 +1,16 @@
# Generated by Django 3.2.8 on 2022-01-07 02:00
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0025_auto_20220107_0158'),
]
operations = [
migrations.DeleteModel(
name='Label',
),
]

backend/api/migrations/0025_auto_20211222_0454.py → backend/api/migrations/0027_auto_20211222_0454.py

@ -7,7 +7,7 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('api', '0024_auto_20211221_1444'),
('api', '0026_auto_20220107_0200'),
]
operations = [
Loading…
Cancel
Save