diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-03-09 13:31:39 -0800 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-03-26 11:39:07 -0700 |
commit | 05879c1c76045679eae5110c7580f9e0533dfd8c (patch) | |
tree | e4878e396745f25c080db8356666d86ec5306784 /mediagoblin/gmg_commands | |
parent | 731df78225cfeed168b849287ede07e205fae3f3 (diff) | |
download | mediagoblin-05879c1c76045679eae5110c7580f9e0533dfd8c.tar.lz mediagoblin-05879c1c76045679eae5110c7580f9e0533dfd8c.tar.xz mediagoblin-05879c1c76045679eae5110c7580f9e0533dfd8c.zip |
dbupdate updates to use plugin migrations if available
This makes use of the recently added "build_alembic_config" tool and
removes AlembicMigrationManager.
* mediagoblin/db/migration_tools.py (AlembicMigrationManager): Removed.
* mediagoblin/gmg_commands/dbupdate.py (run_alembic_migrations):
Adjusted to use recently added build_alembic_config tool.
Diffstat (limited to 'mediagoblin/gmg_commands')
-rw-r--r-- | mediagoblin/gmg_commands/dbupdate.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index 6227ad0e..e9f05e01 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -17,10 +17,12 @@ import logging import six +from alembic import command from sqlalchemy.orm import sessionmaker from mediagoblin.db.open import setup_connection_and_db_from_config -from mediagoblin.db.migration_tools import MigrationManager, AlembicMigrationManager +from mediagoblin.db.migration_tools import ( + MigrationManager, build_alembic_config) from mediagoblin.init import setup_global_and_app_config from mediagoblin.tools.common import import_component @@ -112,8 +114,15 @@ def gather_database_data(plugins): def run_alembic_migrations(db, app_config, global_config): """Initialize a database and runs all Alembic migrations.""" Session = sessionmaker(bind=db.engine) - manager = AlembicMigrationManager(Session()) - manager.init_or_migrate() + session = Session() + cfg = build_alembic_config(global_config, None, session) + + # XXX: we need to call this method when we ditch + # sqlalchemy-migrate entirely + # if self.get_current_revision() is None: + # self.init_tables() + return command.upgrade(cfg, 'heads') + def run_dbupdate(app_config, global_config): |