Skip to content

Commit

Permalink
fix(template): migrate group to meta property before removing
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Jul 24, 2023
1 parent 02bf59a commit 4480877
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@
from django.db import migrations


def migrate_group_to_meta(apps, schema_editor):
Template = apps.get_model("api", "Template")

for template in Template.objects.filter(group__isnull=False):
template.meta["group"] = template.group
template.save()


def migrate_group_to_meta_reverse(apps, schema_editor):
Template = apps.get_model("api", "Template")

for template in Template.objects.filter(meta__has_key="group"):
template.group = template.meta["group"]
del template.meta["group"]
template.save()


class Migration(migrations.Migration):
dependencies = [
("api", "0005_xlsx_template_engine"),
]

operations = [
migrations.RunPython(migrate_group_to_meta, migrate_group_to_meta_reverse),
migrations.RemoveField(
model_name="template",
name="group",
Expand Down

0 comments on commit 4480877

Please sign in to comment.