Based on https://github.com/ietf-tools/wagtail_website/pull/365, this PR changes how the UNIQUE constraint is applied to the slug field. The initial code (currently in main) would create the field with the UNIQUE flag already set, before the data migration had a chance to generate values and populate the field, so all records had a value of "" (empty string), which failed the constraint.
The constraint, then, should be applied after the slugs are generated. Normally it's possible to add such constraints in the same migration, right after the RunPython step, but in this case, it triggers this bug: https://code.djangoproject.com/ticket/28646. That's why the unique flag is added in the 0004_merge_20231215_0352 migration.
Fixes https://github.com/ietf-tools/wagtail_website/issues/364.
Based on https://github.com/ietf-tools/wagtail_website/pull/365, this PR changes how the UNIQUE constraint is applied to the slug field. The initial code (currently in
main
) would create the field with the UNIQUE flag already set, before the data migration had a chance to generate values and populate the field, so all records had a value of""
(empty string), which failed the constraint.The constraint, then, should be applied after the slugs are generated. Normally it's possible to add such constraints in the same migration, right after the
RunPython
step, but in this case, it triggers this bug: https://code.djangoproject.com/ticket/28646. That's why the unique flag is added in the0004_merge_20231215_0352
migration.