is it possible to prevent alembic upgrade
from working unless the database has been initialized with alembic stamp
?
#1716
-
is it possible to prevent I adopted Alembic on a project with multiple deployments. Some nodes received an emergency manual hotfix of sql code, and don't need the first alembic migration. These fail and need a manual cleanup if the new Alembic code gets deployed to them. I'd just like to fail |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi, I don't think you want stamp, since that will write the head migration(s) to the version tables, so that afterward no other migration will be run, since alembic sees them as already fully applied |
Beta Was this translation helpful? Give feedback.
-
you can look for alembic version table in env.py using |
Beta Was this translation helpful? Give feedback.
you can look for alembic version table in env.py using
inspect(connection).has_table("alembic_version")
. for stamp you'd need to check if some version that you expect is in the table, we dont exactly have an "is_version_applied" method, you'd need to look at what version is present and then walk the revision tree to see if it's a descendant of the version you expect, if that's what you really want here. look in the source for the ";history" command to see how to get this data