well, the "alembic current" command gives you the current status of
the revisions in the database, and the "alembic heads" command shows
you the current "head" versions represented in the versions/
directory. These used to both be just a single value, but now that
Alembic supports branches they can be lists of values.
if you look in
http://alembic.zzzcomputing.com/en/latest/api/runtime.html?highlight=migrationcontext#alembic.runtime.migration.MigrationContext,
there's an example of how to get the database version:
# in any application, outside of an env.py script
from alembic.migration import MigrationContext
from sqlalchemy import create_engine
engine = create_engine("postgresql://mydatabase")
conn = engine.connect()
context = MigrationContext.configure(conn)
current_rev = context.get_current_revision()
similarly, the ScriptDirectory can get you those "heads" from your
versions/ directory, and the docstring at
http://alembic.zzzcomputing.com/en/latest/api/script.html?highlight=scriptdirectory#alembic.script.ScriptDirectory
also illustrates this:
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()
the above two examples illustrate the "single head" version. For
branch support, you'd use context.get_current_heads() and
script.get_heads(). the docstrings for those methods should link to
all of this.
>
> Best,
> Jannis
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sqlalchemy-alem...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.