diff options
| author | Barry Warsaw | 2015-01-20 17:37:20 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2015-01-20 17:37:20 -0500 |
| commit | a912da8cf311bdb0a8be334950878f6c2a996bb7 (patch) | |
| tree | 21d3ea94ea4c6a29798f50a8aa2008c2106ef8c5 /src/mailman/database | |
| parent | 5b1640705a9823b274405523103ca5d3400423b1 (diff) | |
| parent | 95e0ff2a7473d5f3eb3ab1df0ad08462d7bebc90 (diff) | |
| download | mailman-a912da8cf311bdb0a8be334950878f6c2a996bb7.tar.gz mailman-a912da8cf311bdb0a8be334950878f6c2a996bb7.tar.zst mailman-a912da8cf311bdb0a8be334950878f6c2a996bb7.zip | |
* Improve the documentation describing how to run Alembic to add new schema
migrations. Given by Abhilash Raj.
Diffstat (limited to 'src/mailman/database')
| -rw-r--r-- | src/mailman/database/alembic/env.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py index 5fb9ac138..a039a20e6 100644 --- a/src/mailman/database/alembic/env.py +++ b/src/mailman/database/alembic/env.py @@ -25,11 +25,18 @@ __all__ = [ from alembic import context from contextlib import closing +from mailman.core.initialize import initialize_1 from mailman.config import config from mailman.database.model import Model from mailman.utilities.string import expand from sqlalchemy import create_engine +try: + url = expand(config.database.url, config.paths) +except AttributeError: + # Initialize config object for external alembic calls + initialize_1() + url = expand(config.database.url, config.paths) def run_migrations_offline(): @@ -42,7 +49,6 @@ def run_migrations_offline(): Calls to context.execute() here emit the given string to the script output. """ - url = expand(config.database.url, config.paths) context.configure(url=url, target_metadata=Model.metadata) with context.begin_transaction(): context.run_migrations() @@ -54,7 +60,6 @@ def run_migrations_online(): In this scenario we need to create an Engine and associate a connection with the context. """ - url = expand(config.database.url, config.paths) engine = create_engine(url) connection = engine.connect() |
