Skip to content

Commit a67d9d3

Browse files
committed
FPR: fix downgrade path in migration fpr.0029
This commit fixes the `data_migration_down` function in the migration introduced by the previous commit to ensure that the order of the operations is incorrect and the migration can be properly reverted. Connects to archivematica/Issues#537.
1 parent aed4fa0 commit a67d9d3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/dashboard/src/fpr/migrations/0029_update_inkscape_svg_command.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@ def data_migration_down(apps, schema_editor):
6060
FPCommand = apps.get_model('fpr', 'FPCommand')
6161
FPRule = apps.get_model('fpr', 'FPRule')
6262

63-
FPCommand.objects.filter(uuid=NEW_INKSCAPE_CMD_UUID).delete()
64-
63+
# The order matters. We make sure that the rules point to the previous
64+
# command before the latter is deleted. Otherwise our rules would be
65+
# deleted by Django's on cascade mechanism.
6566
FPRule.objects \
6667
.filter(uuid__in=INKSCAPE_SVG_RULES) \
6768
.update(command_id=OLD_INKSCAPE_CMD_UUID)
6869

70+
FPCommand.objects.filter(uuid=NEW_INKSCAPE_CMD_UUID).delete()
71+
6972

7073
class Migration(migrations.Migration):
7174

0 commit comments

Comments
 (0)