Created
March 28, 2013 22:00
-
-
Save charlax/5267192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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