Skip to content

Commit a4297b9

Browse files
committed
feat(local_units): Migrate validated LocalUnit status
1 parent 9b1f315 commit a4297b9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 4.2.19 on 2025-08-12 21:39
2+
3+
from django.db import migrations
4+
5+
6+
def migrate_validated_to_status(apps, schema_editor):
7+
"""
8+
Update all validated field values to corresponding status values
9+
"""
10+
LocalUnit = apps.get_model("local_units", "LocalUnit")
11+
LocalUnit.objects.filter(validated=True).update(status=1) # 1 for Validated
12+
LocalUnit.objects.filter(validated=False).update(status=2) # 2 for Unvalidated
13+
14+
15+
class Migration(migrations.Migration):
16+
17+
dependencies = [
18+
("local_units", "0021_localunit_is_new_local_unit_localunit_status_and_more"),
19+
]
20+
21+
operations = [
22+
migrations.RunPython(
23+
migrate_validated_to_status,
24+
reverse_code=migrations.RunPython.noop,
25+
),
26+
]

0 commit comments

Comments
 (0)