Abhilash Raj has proposed merging lp:~raj-abhilash1/mailman/alembic-fix into
lp:mailman.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~raj-abhilash1/mailman/alembic-fix/+merge/246026
Fixed the autogeneration of migrations using alembic.
--
Your team Mailman Coders is requested to review the proposed merge of
lp:~raj-abhilash1/mailman/alembic-fix into lp:mailman.
=== modified file 'src/mailman/database/alembic/env.py'
--- src/mailman/database/alembic/env.py 2015-01-05 01:22:39 +0000
+++ src/mailman/database/alembic/env.py 2015-01-09 23:44:45 +0000
@@ -25,11 +25,18 @@
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 @@
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 @@
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()
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders