Open jrobichaud opened 1 year ago
hi @jrobichaud 👋
That's an interesting idea. Could you please prepare the simplest possible example - the simplest Django project reflecting migrations from your message, so we can play with it and craft the best possible solution to handle all (or most 😄) cases?
@skarzi, there you go: https://github.com/jrobichaud/django-test-migrations-398
I made sure to recreate the exact migrations with the exact numbers.
See the readme for the explanations.
I just added CI execution, we can see in the develop branch the migration test fails.
main: https://github.com/jrobichaud/django-test-migrations-398/actions/runs/7305056864/job/19908143449#step:5:17 develop: https://github.com/jrobichaud/django-test-migrations-398/actions/runs/7305060018/job/19908150801#step:5:34
Context
I have a project with multiple apps (Ex: App A and app B).
I once in a while code migrations with tests based on the state of the DB at that time.
Lately I added a new
nullable
field on my Old model in app A, a migration to fill the field then make itnon-nullable
. Everything was working properly except one thing, an old migration test started to fail.The old migration tests for app B started to fail because back then that field did not exist but my app A was being fully migrated.
It did not make any sense until I realized
truncate_plan
only truncate the end of the migrations plan and not the apps separately.Explanations
Lets say I have migrations in each apps that were added in that chronological order:
The migration test is specified like this:
However in practice when the test is ran the full plan looks like this:
The truncate plan A4 B4 will result to start dropping everything after index of B4 with the current implementation:
However I would expect
truncate_plan
A4 B4 to truncate per app independently like this: