Skip to content

Commit f658455

Browse files
committed
feat(dref): migrate original_language field with 'en' for existing records
1 parent 703936d commit f658455

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dref/migrations/0086_alter_dref_status_alter_dreffinalreport_status_and_more.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
from django.db import migrations, models
44

55

6+
def update_original_language(apps, schema_editor):
7+
"""
8+
Populate the original_language field with 'en' for all existing records.
9+
"""
10+
models = [
11+
"Dref",
12+
"DrefOperationalUpdate",
13+
"DrefFinalReport",
14+
]
15+
for model_name in models:
16+
Model = apps.get_model("dref", model_name)
17+
Model.objects.filter(original_language__isnull=True).update(original_language="en")
18+
19+
620
class Migration(migrations.Migration):
721

822
dependencies = [
@@ -25,4 +39,5 @@ class Migration(migrations.Migration):
2539
name='status',
2640
field=models.IntegerField(choices=[(1, 'Draft'), (2, 'Finalized'), (3, 'Approved')], default=1, verbose_name='status'),
2741
),
42+
migrations.RunPython(update_original_language,reverse_code=migrations.RunPython.noop)
2843
]

0 commit comments

Comments
 (0)