Skip to content
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

upgrade and downgrade expect target to be relative revision #45

Open
Lukas0907 opened this issue Oct 28, 2024 · 2 comments
Open

upgrade and downgrade expect target to be relative revision #45

Lukas0907 opened this issue Oct 28, 2024 · 2 comments

Comments

@Lukas0907
Copy link

Lukas0907 commented Oct 28, 2024

The downgrade and upgrade commands expect the the target revision to always be relative. Therefore, e.g. flask db downgrade 1730111612 would try to revert the last 1730111612 revisions instead of downgrading to the specific revision. Alembic and flask-alembic accept "absolute" revisions as well (cf. https://alembic.sqlalchemy.org/en/latest/tutorial.html#partial-revision-identifiers) so this was surprising to me.

Maybe this could be changed, or mentioned in the docs.

Thanks!

@davidism
Copy link
Member

I bet this is an unexpected interaction with making rev_id a timestamp rather than random string. I pretty much only use relative numbers, so I made it unnecessary to enter + or -. When rev id was random, int(rev_id) was unlikely to succeed unless it was intentionally a number and not an id. But now there's no way to distinguish ids from relative numbers.

@Lukas0907
Copy link
Author

Right, that makes sense. Using the upstream rev_id() function (basically reverting bd8b43e) seems to restore the old behavior:

from alembic import util as alembic_util

alembic.init_app(app)
alembic.rev_id = alembic_util.rev_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants