diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-03-05 17:37:58 -0800 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-03-26 11:39:07 -0700 |
commit | 6e9041aa4bab0761c3772d44a3b8a5a5005261e2 (patch) | |
tree | 4aa81566dae15a56232a74639b480d9f9e0d90bb /mediagoblin/gmg_commands/alembic_commands.py | |
parent | 3f08f780f6698622dba0e8de74ece9194fdb7726 (diff) | |
download | mediagoblin-6e9041aa4bab0761c3772d44a3b8a5a5005261e2.tar.lz mediagoblin-6e9041aa4bab0761c3772d44a3b8a5a5005261e2.tar.xz mediagoblin-6e9041aa4bab0761c3772d44a3b8a5a5005261e2.zip |
Add build_alembic_config, use it to add plugin migrations to alembic config
Diffstat (limited to 'mediagoblin/gmg_commands/alembic_commands.py')
-rw-r--r-- | mediagoblin/gmg_commands/alembic_commands.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/mediagoblin/gmg_commands/alembic_commands.py b/mediagoblin/gmg_commands/alembic_commands.py index f255af73..58b931dc 100644 --- a/mediagoblin/gmg_commands/alembic_commands.py +++ b/mediagoblin/gmg_commands/alembic_commands.py @@ -15,17 +15,17 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import argparse -import os from alembic import config from sqlalchemy.orm import sessionmaker from mediagoblin.db.open import setup_connection_and_db_from_config from mediagoblin.init import setup_global_and_app_config +from mediagoblin.db.migration_tools import build_alembic_config class FudgedCommandLine(config.CommandLine): - def main(self, args, db): + def main(self, args, db, global_config): options = self.parser.parse_args(args.args_for_alembic) # This code is inspired by a hack in Alembic, but isn't the same really. # Regardless, Alembic is Expat licensed. @@ -38,13 +38,10 @@ class FudgedCommandLine(config.CommandLine): return else: Session = sessionmaker(bind=db.engine) + session = Session() + + cfg = build_alembic_config(global_config, options, session) - root_dir = os.path.abspath(os.path.dirname(os.path.dirname( - os.path.dirname(__file__)))) - alembic_cfg_path = os.path.join(root_dir, 'alembic.ini') - cfg = config.Config(alembic_cfg_path, - cmd_opts=options) - cfg.attributes["session"] = Session() self.run_cmd(cfg, options) def parser_setup(subparser): @@ -53,4 +50,4 @@ def parser_setup(subparser): def raw_alembic_cli(args): global_config, app_config = setup_global_and_app_config(args.conf_file) db = setup_connection_and_db_from_config(app_config, migrations=False) - FudgedCommandLine().main(args, db) + FudgedCommandLine().main(args, db, global_config) |