Jon Rosebaugh
2015-07-07 15:44:35 UTC
We have a test server where we automatically deploy various git branches
of our codebase; these git branches sometimes have different Alembic
heads and so the database needs to be upgraded or downgraded. For a long
time we enforced a linear Alembic history and so this was relatively
easy to automate.
We want to allow branching and merging now, which means we may have
problems. Consider the following tree:
A -> B1 -> C
A -> B2 -> C
A -> B2 -> D
(Where A is the a common parent, B1 and B2 are two branching revisions,
C is a merge revisions, and D is a revisions whose parent is B2.)
If I deploy a branch with C, but not D to the test server, and the
database is currently at A, then we can automatically upgrade to
revision C, which runs B1 upgrade, B2 upgrade, and C upgrade.
Then I deploy a branch with D, but not B1 or C, to the test server. This
means that for this branch, the database should reflect A -> B2 -> D. I
want to downgrade C, downgrade B1, but not downgrade B2, then upgrade to
D. I could approximate this situation by downgrading all the way to A,
and upgrading back to B2, but if B2 is a migration that takes a while,
that would be annoying.
What is the best way to accomplish this? Essentially I want to take a
set of revisions including the HEAD revision and remove them from the
database. Is this what the "relnum+delta" specification syntax is for?
of our codebase; these git branches sometimes have different Alembic
heads and so the database needs to be upgraded or downgraded. For a long
time we enforced a linear Alembic history and so this was relatively
easy to automate.
We want to allow branching and merging now, which means we may have
problems. Consider the following tree:
A -> B1 -> C
A -> B2 -> C
A -> B2 -> D
(Where A is the a common parent, B1 and B2 are two branching revisions,
C is a merge revisions, and D is a revisions whose parent is B2.)
If I deploy a branch with C, but not D to the test server, and the
database is currently at A, then we can automatically upgrade to
revision C, which runs B1 upgrade, B2 upgrade, and C upgrade.
Then I deploy a branch with D, but not B1 or C, to the test server. This
means that for this branch, the database should reflect A -> B2 -> D. I
want to downgrade C, downgrade B1, but not downgrade B2, then upgrade to
D. I could approximate this situation by downgrading all the way to A,
and upgrading back to B2, but if B2 is a migration that takes a while,
that would be annoying.
What is the best way to accomplish this? Essentially I want to take a
set of revisions including the HEAD revision and remove them from the
database. Is this what the "relnum+delta" specification syntax is for?
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.