Merge conflicting db migration branches into one #15771
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is meant to replace #15768.
The core issue is explained in #15768. Here's a visualization of what happened and the 2 solutions. From left to right:
Why is this a problem? Because when we want to upgrade, alembic can't know what head we want to upgrade to.
down_revision
value in d058, "rebasing" it onto caa7, thus rearranging the graph to have 1 gxy head(with
./scripts/run_alembic.sh merge caa7 9540
), thus restoring 1 gxy headWhy renaming is not a good solution
If we start with the pre-conflict dev branch (normal case for a development setup), the
alembic_version
table in the database will contain revisions 9540 and d4a6 (d4a6 is the tsi branch, so it's irrelevant in this context). Once we pull from upstream, we get the 2 new revisions from the merged-in 23.0 branch (3a29 and caa7), resulting in 2 gxy heads. We rename the down_migration in d058, effectively hiding 3a29 and caa7 from the database (@natefoo that's the problem case you referred to). So, running `manage_db.sh upgrade will be a noop, and the 2 indexes won't be added.By adding an explicit merge revision, we reconcile the diverged branches, while ensuring that revisions won't be silenced.
How to test the changes?
(Select all options that apply)
No easy way to set this up. Here's gist with a transcript of some of the testing I did of this approach. In summary:
manage_db.sh init
(verify version, dbversion, and history after each step).
License