You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 it non-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 truncate plan A4 B4 will result to start dropping everything after index of B4 with the current implementation:
A1A2A3A4A5A6 (Addnewnullablefieldhere)
A7 (MigrationtofillthefieldintheDB)
A8 (Migrationtomakefieldnon-nullable)
B1B2B3 (hasexplicitdependencytoA3here)
B4# B5 (this is a custom migration) <- REMOVAL FROM PLAN BEGINS AT THIS INDEX# B6
However I would expect truncate_plan A4 B4 to truncate per app independently like this:
A1A2A3A4# A5 <- REMOVED BECAUSE IT IS ABOVE A4# A6 (Add new nullable field here) <- REMOVED FROM PLAN BECAUSE IT IS ABOVE A4# A7 (Migration to fill the field in the DB) <- REMOVED FROM PLAN BECAUSE IT IS ABOVE A4# A8 (Migration to make field non-nullable) <- REMOVED FROM PLAN BECAUSE IT IS ABOVE A4B1B2B3 (hasexplicitdependencytoA3here)
B4# B5 (this is a custom migration) <- REMOVED FROM PLAN BECAUSE IT IS ABOVE B4# B6 <- REMOVED FROM PLAN BECAUSE IT IS ABOVE B4
The text was updated successfully, but these errors were encountered:
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?
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:The text was updated successfully, but these errors were encountered: