Add initial Alembic migrations.

This commit is contained in:
Berker Peksag
2014-08-13 19:30:23 +03:00
parent 7df0793441
commit 65f20ca435
8 changed files with 191 additions and 0 deletions

View File

@@ -106,6 +106,13 @@ forgotten to add it? ({1})'.format(plugin, exc))
return managed_dbdata
def run_alembic_migrations(db, app_config, global_config):
from mediagoblin.db.migration_tools import AlembicMigrationManager
Session = sessionmaker(bind=db.engine)
manager = AlembicMigrationManager(Session())
manager.init_or_migrate()
def run_dbupdate(app_config, global_config):
"""
Initialize or migrate the database as specified by the config file.
@@ -118,6 +125,7 @@ def run_dbupdate(app_config, global_config):
db = setup_connection_and_db_from_config(app_config, migrations=True)
# Run the migrations
run_all_migrations(db, app_config, global_config)
run_alembic_migrations(db, app_config, global_config)
def run_all_migrations(db, app_config, global_config):