432_Unreadable_payments #434
@ -1,5 +1,6 @@
|
||||
# Generated by Django 5.0.7 on 2024-08-06 13:40
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import migrations
|
||||
from django.db.models import Q
|
||||
|
||||
@ -10,9 +11,12 @@ def migrate_975_to_288(apps, schema_editor):
|
||||
KonovaCodeList = apps.get_model('codelist', 'KonovaCodeList')
|
||||
CompensationState = apps.get_model('compensation', 'CompensationState')
|
||||
|
||||
try:
|
||||
list_288 = KonovaCodeList.objects.get(
|
||||
id=CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||
).codes.all()
|
||||
except ObjectDoesNotExist:
|
||||
raise AssertionError("KonovaCodeList 288 does not exist. Did you run 'update_codelist' before migrating?")
|
||||
|
||||
states_with_extra_code = CompensationState.objects.filter(
|
||||
~Q(biotope_type_details=None)
|
||||
@ -42,8 +46,15 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('codelist', '0001_initial'),
|
||||
('compensation', '0003_auto_20220202_0846'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_975_to_288)
|
||||
]
|
||||
# If migration of codelist is not necessary, this variable can shut down the logic whilst not disturbing the
|
||||
# migration history
|
||||
EXECUTE_CODELIST_MIGRATION = True
|
||||
|
||||
operations = []
|
||||
|
||||
if EXECUTE_CODELIST_MIGRATION:
|
||||
operations.append(migrations.RunPython(migrate_975_to_288))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user