-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit revision sequence? #17
Comments
Tangentially related to #18 |
I think the ideal approach would be to ditch timestamps and just do a straight sequence...
Using a sequence gives ordering of timestamps (as opposed to the If people merge conflicting histories (or journeys, to stick with the cheesy language) then they just change filenames, rather than pointers in-file.
CAVEATSwitching to a sequence is not backwards-compatible |
Added via #19 |
Unlike pure timestamp-based revision tools,
alembic
requires each revision to explicitly state which it follows, and it errors if two point to the same "down" revision. Unfortunately, allalembic
tracks is the last version applied, which is actually problematic if...master
branch has revisionA
feature-1
branch and writes revisionB
feature-2
branch and writes revisionC
feature-1
tomaster
and creates historyA <- B
master
intofeature-2
to resolve conflicts and effectively now has two historiesA <- B | A <- C
B
to point to revisionC
instead of revisionA
, such thatA <- C <- B
feature-2
intomaster
In this situation, because the
alembic_version
stored in the database (from step 4) isB
,alembic
assumes that anything before it has already been applied and will actually never executeC
. Sure, this is kind of a breakdown in workflow and (hopefully) doesn't happen often in practice, but it's potentially hard to spot for subtler changes (like adding an index, changing a check constraint, etc) that might not break tests.Unfortunately, the simpler timestamp approach inspired by active-record or dbmate (which is great for sorting through revisions) that is currently used is also problematic because it absolutely allows applying revisions in different orders.
For instance, in the above example, both Alice and Bob could merge their revisions into
master
, but if Bob merged first and CI ran migrations prior to Alice merging (for instance, in a dev server) then revisions would ultimately have been executed in the orderA -> C -> B
. Ifmaster
is then merged into arelease
branch or something, both revisions would be present at the same time and would be run in the orderA -> B -> C
sinceB
has an earlier timestamp.In the unfortunate situation where both Alice's and Bob's revisions touched a similar object (table, index, etc) then any database migrated by
master
could easily differ from any database migrated viarelease
.So... what's the answer?
The text was updated successfully, but these errors were encountered: