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
Downgrade for just one branch from multi heads #464
Comments
Michael Bayer (@zzzeek) wrote: unfortunately this is extremely complicated as there are scenarios where those other branches must be pulled down. I will leave this open but I'm unlikely to have a good solution for this anytime soon. |
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: the idea is that given:
if im on "rev2" / "rev3a" and i say:
it would figure out we don't need to do rev2. A quick patch that does this is:
but this breaks tests for the situation where we do need to still pull down rev2, including if we said to go all the way to the base, as well as when other branches have dependencies on one of the revisions that we're removing. so it would need to figure out "preferred" heads to bring down but also still figure out other heads that have to come down. |
dem0n3d (@dem0n3d) wrote: I wish to alembic have operation like git "checkout": when you specify revision (or branch), alembic ensures that db migrated to this state (and only this). But I realize that it is too complicated :) Maybe somethink like "downgrade revision range"?
Or simply add some CLI options to your solution? |
Interested to discuss & implement this if it is still going to be useful for others. I'm using alembic to manage multiple branches and ran into similar issues trying to wind back a single branch to a branchpoint reliably. I have a rough concept for an
Roughly the idea is to:
Happy to put a PR together for this but are there are other cases that should be covered or should a different API be used? |
hey there - this sounds interesting though I would have much to learn. For example, why is it called "alembic checkout"? if one wants to "downgrade" I would think they'd be using the "downgrade" command ? |
or is this command of a more general scope? "checkout" from tools like git sounds like a passive command but running upgrades and downgrades is not a passive operation. |
Ah, I went with the OP's suggestion of "checkout" but hadn't thought about this, makes sense. I was thinking of a very general operation that runs upgrades and downgrades as necessary to migrate the database to a fixed state. So the OPs of these issues are after in general: Initial state:
Final state after some alembic operation (doesn't seem to currently be possible as
I'm suggesting |
can you review my comment at #464 (comment) and see if the proposed syntax (which is a syntax we already have, branch@revision, will work, that is:
see https://alembic.sqlalchemy.org/en/latest/branches.html#working-with-branch-labels for a description of this syntax. in "branch@revision" syntax, anything on the left side that identifies a particular branch, like a specific rev, or a branch label, etc., will work, it's all the same thing. |
… to play with).
Yes I can see that this syntax makes more sense to downgrade a specific branch. Your suggested patch handles the labelled branch case as long as the labelled revision is a current head. I'll attempt a PR for a more general approach. I found a few odd quirks (I think) of |
Add tests for downgrade of single branch to branch point.
…a specific branch to be downgraded. Add test cases for branch/revision@target syntax. Fixes: sqlalchemy#464
…a specific branch to be downgraded. Add test cases for branch/revision@target syntax. Fixes: sqlalchemy#464
…a specific branch to be downgraded. Add test cases for branch/revision@target syntax. Fixes: sqlalchemy#464
Fixes $765. Fixes sqlalchemy#464.
Fixes $765. Fixes sqlalchemy#464.
Simon Bowly has proposed a fix for this issue in the master branch: New downgrade algorithm to fix branch behaviour https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/2530 |
Migrated issue, originally created by dem0n3d (@dem0n3d)
I frequently need possibility to downgrade just one of my heads to branchpoint, but alembic tries to downgrade all of them. Can you implement this feature, please?
The text was updated successfully, but these errors were encountered: