Skip to content
Snippets Groups Projects
Commit e8b8100d authored by Alexa Valentová's avatar Alexa Valentová
Browse files

fix migrations

parent 8a6fb2d0
No related branches found
No related tags found
2 merge requests!1139Release,!1138fix migrations
Pipeline #19767 passed
...@@ -4,6 +4,7 @@ import wagtail ...@@ -4,6 +4,7 @@ import wagtail
from django.apps import apps as base_apps from django.apps import apps as base_apps
from django.contrib.contenttypes.management import create_contenttypes from django.contrib.contenttypes.management import create_contenttypes
from django.db import migrations, transaction from django.db import migrations, transaction
from django.db.utils import IntegrityError
from wagtail.blocks import CharBlock, RichTextBlock, StreamBlock, StructBlock from wagtail.blocks import CharBlock, RichTextBlock, StreamBlock, StructBlock
from district.blocks import ( from district.blocks import (
...@@ -18,6 +19,8 @@ from shared.blocks import SocialLinkBlock ...@@ -18,6 +19,8 @@ from shared.blocks import SocialLinkBlock
def migrate_programs(apps, schema_editor): def migrate_programs(apps, schema_editor):
try:
with transaction.atomic():
# Copy this block manually here, as it has been changed in future migrations. # Copy this block manually here, as it has been changed in future migrations.
class ProgramGroupWithCandidatesBlock(StructBlock): class ProgramGroupWithCandidatesBlock(StructBlock):
title = CharBlock( title = CharBlock(
...@@ -529,7 +532,12 @@ def migrate_programs(apps, schema_editor): ...@@ -529,7 +532,12 @@ def migrate_programs(apps, schema_editor):
new_program_page.program.append( new_program_page.program.append(
("program_group_with_candidates", new_program_block) ("program_group_with_candidates", new_program_block)
) )
new_program_page.save() new_program_page.save()
except Exception as e:
print(f"Ignoring exception during program page migration: {e}")
pass
class Migration(migrations.Migration): class Migration(migrations.Migration):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment