How can I access the "current" revision after the migration has run *inside* the env.py script? #1667
-
I would like to run an automation task whenever a migration task finishes successfully. At first I tried parsing the revision myself including the complexities with the I realised that I could potentially also use So I tried to run How else can I retrieve the revision hash after migrations have finished? For context: I am dumping a snapshot of the resulting DB-schema (without data) after migration for other housekeeping tasks (integration tests). For that schema to be valid, I need to run an INSERT statement with the revision-hash that corresponds to that schema. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
that would not be the issue there unless you have other connections opened, the transaction scope is entirely under your control in the env.py file in your project.
|
Beta Was this translation helpful? Give feedback.
that would not be the issue there unless you have other connections opened, the transaction scope is entirely under your control in the env.py file in your project.
alembic current
works with what you are calling a "side effect" because alembic relies exclusively on the env.py file and it's transaction block to gain connectivity. however, if you have a connection already and want to use that to get "current" for the database referenced by that connection, you can use the API directly and you can …