I'm working on a project with multiple branches, and I'm finding something funny when running my migrations...
I have a main
branch that has the following revisions: A --> B --> C
And then a dev branch with B' --> C'
B'
depends on B
, and C'
depends on C
C
has breaking changes that prevent you from running B'
after it
Now, my expectation was that if I ran alembic upgrade dev@head
I would get the following order of executions:
A --> B --> B' --> C --> C'
With the execution sort of jumping back and forth between the main and the dev branch following a sort of "chronological" order.
However, what I'm getting is
A --> B --> C --> B' --> C'
Is there anything I can do to get A --> B --> B' --> C --> C'
?
Thanks, Fernando
I got an answer in the Discussions section of the Alembic repo from zzzeek himself about this:
if there's no relationship between C and B' then yes it's expected that these two migrations may occur in any order. So if your migrations have an ordering requirement that C must occur after B', add this relationship using a dependency, that is, the depends_on label. see that documented section for examples, here you'd want to make C dependent on B'.
And, the mentioned docs are these