summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhilash Raj2014-09-25 02:53:09 +0530
committerAbhilash Raj2014-09-25 02:53:09 +0530
commit03647b16eb75cc841bb15c3c48ac5f18f77118b8 (patch)
treedb79e553c470384046f5d4a130e7f7b9d90eceb7
parent32d118329488df775cd74dad2907ed496022f757 (diff)
downloadmailman-03647b16eb75cc841bb15c3c48ac5f18f77118b8.tar.gz
mailman-03647b16eb75cc841bb15c3c48ac5f18f77118b8.tar.zst
mailman-03647b16eb75cc841bb15c3c48ac5f18f77118b8.zip
-rw-r--r--src/mailman/commands/cli_migrate.py13
-rw-r--r--src/mailman/database/alembic/env.py3
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,