Skip to content

Commit

Permalink
Remove squashed migration and rely on run_before
Browse files Browse the repository at this point in the history
The initial migration must continue to rely on the historical
PageRevision model. Changing it to the generic revision model may cause
errors with existing databases that have migrations applied in a certain
order.

New databases won't be able to migrate because they have no history and
try to migrate the initial migration using the PageRevision model _after_
it was removed by Wagtail's migrations. To combat this, we add `run_before`
to ensure we run the initial migration _before_ the PageRevision model is
removed by Wagtail's migrations.

I feel like this is a better solution then squashing the migration
history.
  • Loading branch information
Stormheg committed Jul 27, 2023
1 parent 3a557fb commit 27eb9bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 214 deletions.
6 changes: 6 additions & 0 deletions wagtail_ab_testing/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class Migration(migrations.Migration):
('wagtailcore', '0052_pagelogentry'),
]

# Added for compatibility with Wagtail 4+
# This migration references the old PageRevision model and must run before it was migrated to a generic Revision model
run_before = [
("wagtailcore", "0070_rename_pagerevision_revision")
]

operations = [
migrations.CreateModel(
name='AbTest',
Expand Down

This file was deleted.

20 changes: 0 additions & 20 deletions wagtail_ab_testing/migrations/0012_abtest_variant_revision.py

This file was deleted.

0 comments on commit 27eb9bb

Please sign in to comment.