diff options
Diffstat (limited to 'mediagoblin/db/migration_tools.py')
-rw-r--r-- | mediagoblin/db/migration_tools.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mediagoblin/db/migration_tools.py b/mediagoblin/db/migration_tools.py index e34685f5..b3fb8f41 100644 --- a/mediagoblin/db/migration_tools.py +++ b/mediagoblin/db/migration_tools.py @@ -40,10 +40,17 @@ class AlembicMigrationManager(object): def __init__(self, session): root_dir = os.path.abspath(os.path.dirname(os.path.dirname( os.path.dirname(__file__)))) + + self.session = session + self.engine = self.session.get_bind() alembic_cfg_path = os.path.join(root_dir, 'alembic.ini') self.alembic_cfg = Config(alembic_cfg_path) - self.alembic_cfg.set_main_option("sqlalchemy.url", str(session.get_bind().url)) - self.session = session + + # TODO: After 0.7.5 alembic has Config.attributes already made, once + # we're able to update, please remove this hack! + self.alembic_cfg.attributes = {} + self.alembic_cfg.attributes["session"] = self.session + self.alembic_cfg.set_main_option("qlalchemy.url", str(self.engine.url)) def get_current_revision(self): context = MigrationContext.configure(self.session.bind) |