Skip to content

Instantly share code, notes, and snippets.

@charlax
Created March 28, 2013 22:00
Show Gist options
  • Save charlax/5267192 to your computer and use it in GitHub Desktop.
Save charlax/5267192 to your computer and use it in GitHub Desktop.
from alembic.script import ScriptDirectory
from alembic.config import Config
from alembic.migration import MigrationContext
from sqlalchemy import create_engine
# current head
config = Config()
config.set_main_option("script_location", "myapp:migrations")
script = ScriptDirectory.from_config(config)
head_revision = script.get_current_head()
# version in database
engine = create_engine("postgresql://mydatabase")
conn = engine.connect()
context = MigrationContext.configure(conn)
current_rev = context.get_current_revision()
is_current = current_rev == head_revision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment