Replies: 1 comment
-
correct, these are CLI commands.
you would use the Alembic API below the level of the commands. The second example at https://alembic.sqlalchemy.org/en/latest/api/runtime.html#the-migration-context shows how to get the current revision of a database, given a database connection. |
Beta Was this translation helpful? Give feedback.
-
Firstly, thanks for providing the package... it is my go-to db migration tool!
But I came across something today that I was a bit surprised to find..
I will describe my situation as I may be going about things all wrong..
My app is packaged as a python module and I provide a facade to the alembic commands just to make it easier for my users.
I use the alembic.command module to initiate the required migration actions - all good so far.
The issue I have is that I provide a function to generate the SQL only rather than apply directly to the DB..
I can see that in order to do this type of request, I need the from and to version id's.. No probs, let me do an alembic.command.current and get the current revision that I can feed in as an input to the request..
This is when I discovered that nothing is returned from the
alembic.command.current
function..OK, I could query the alembic_version table directly to get the details, but I would feel a little dirty doing that..
So maybe there is a better way to do what I need, but I would also like to understand if we could get the command functions to return stuff rather than just only printing output.. It does limit it in term of the use cases of facading the alembic module.
Thanks for listening!
Beta Was this translation helpful? Give feedback.
All reactions