diff options
| -rw-r--r-- | src/mailman/commands/cli_migrate.py | 13 | ||||
| -rw-r--r-- | src/mailman/database/alembic/env.py | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/mailman/commands/cli_migrate.py b/src/mailman/commands/cli_migrate.py index 6593ea832..85fd07bd4 100644 --- a/src/mailman/commands/cli_migrate.py +++ b/src/mailman/commands/cli_migrate.py @@ -39,13 +39,20 @@ class Migrate: name = 'migrate' - def add(self, parser, comman_parser): + def add(self, parser, command_parser): """See `ICLISubCommand`.""" + command_parser.add_argument( + '-a', '--autogenerate', + action="store_true", help=_("""\ + Autogenerate the migration script using alembic""")) pass def process(self, args): alembic_cfg= Config() alembic_cfg.set_main_option( "script_location", config.alembic['script_location']) - command.upgrade(alembic_cfg, "head") - print("Updated the database schema.") + if args.autogenerate: + command.revision(alembic_cfg, autogenerate=True) + else: + command.upgrade(alembic_cfg, "head") + print("Updated the database schema.") diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py index 002b11aa1..11ea8f6da 100644 --- a/src/mailman/database/alembic/env.py +++ b/src/mailman/database/alembic/env.py @@ -20,7 +20,6 @@ from __future__ import with_statement from alembic import context from alembic.config import Config from sqlalchemy import create_engine, pool -from logging.config import fileConfig from mailman.config import config from mailman.utilities.string import expand @@ -58,9 +57,9 @@ def run_migrations_online(): alembic_cfg= Config() alembic_cfg.set_main_option( "script_location", config.alembic['script_location']) - url = expand(config.database.url, config.paths) engine = create_engine(url) + connection = engine.connect() context.configure( connection=connection, |
