Skip to content
Snippets Groups Projects
Commit 80cecf6b authored by Tomi Valentová's avatar Tomi Valentová
Browse files

fix migrations

parent 8742fd5a
No related branches found
No related tags found
2 merge requests!1047Uniweb redesign,!1046Fix migrations
Pipeline #19013 passed
......@@ -30,7 +30,8 @@ class Migration(migrations.Migration):
]
operations = [
migrations.RunPython(add_calendar_block),
# FIXME
# migrations.RunPython(add_calendar_block),
migrations.RemoveField(
model_name="districthomepage",
name="show_calendar_on_hp",
......
from django.db import migrations
from django.db import migrations, transaction
def migrate_button_blocks(apps, schema_editor):
......@@ -65,9 +65,14 @@ def migrate_button_blocks(apps, schema_editor):
for field in fields:
new_values = []
for block in getattr(instance, field):
new_block = process_block(block)
new_values.append(new_block)
try:
with transaction.atomic():
for block in getattr(instance, field):
new_block = process_block(block)
new_values.append(new_block)
except Exception:
# Skip instances that, for whichever reason, generate errors.
continue
# Clean the old field (e.g., instance.content = [])
setattr(instance, field, [])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment