Closed sqlalchemy-bot closed 7 years ago
Michael Bayer (zzzeek) wrote:
Return a tuple of the current ‘head versions’ that are represented in the target database.
For a migration stream without branches, this will be a single value, synonymous with that of MigrationContext.get_current_revision().
the correct object is ScriptDirectory, however looks like the docs didn't build correctly. I'm working on fixing that.
When I get those docs back up, this is the code to get the heads in your files:
#!python
from alembic.script import ScriptDirectory
from alembic.config import Config
config = Config()
config.set_main_option("script_location", "myapp:migrations")
script = ScriptDirectory.from_config(config)
head_revision = script.get_current_head()
further question on the mailing list at https://groups.google.com/forum/#!forum/sqlalchemy-alembic, thanks!
Michael Bayer (zzzeek) wrote:
MultiSosnooley (pohmelie) wrote:
Thanks, work as expected!
Migrated issue, originally created by MultiSosnooley (pohmelie)
I'm trying to migrate with alembic from my python program at startup. Documentation said, that I need no config for
MigrationContext
, but it looks like alembic don't know where is my "heads" if there is no config with versions.I am not at head, and alembic know it.
How to fix this? What is the order of creation proper environment for alembic from my custom python program?