Skip to content

Commit

Permalink
fix: migration to add description type based on row type (HL-1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjturt committed Nov 21, 2023
1 parent 40bb4ef commit 36b15ba
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.18 on 2023-11-20 17:28

from django.db import migrations
from calculator.enums import RowType, DescriptionType


def add_description_type(apps, _):
row_model = apps.get_model("calculator", "CalculationRow")
for row in row_model.objects.filter(row_type=RowType.DESCRIPTION):
if row.description_type:
continue
if row.description_fi.startswith("Ajalta"):
row.description_type = DescriptionType.DATE
elif row.description_fi.startswith("Koko ajalta"):
row.description_type = DescriptionType.DATE_TOTAL
elif row.description_fi.startswith("Vähennettävät korvaukset"):
row.description_type = DescriptionType.DEDUCTION
row.save()


class Migration(migrations.Migration):
dependencies = [
("calculator", "0014_add_description_type_to_row"),
]

operations = [
migrations.RunPython(
add_description_type, reverse_code=migrations.RunPython.noop
),
]

0 comments on commit 36b15ba

Please sign in to comment.