From: Mike Bayer Date: Fri, 14 Mar 2014 14:17:37 +0000 (-0400) Subject: - ensure that target_metadata is also present in the offline migration context, X-Git-Tag: rel_0_6_4~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efdf9e408fb10049de5effd3dade6fa276190c4b;p=thirdparty%2Fsqlalchemy%2Falembic.git - ensure that target_metadata is also present in the offline migration context, so that --sql mode gets access to naming conventions also. existing environments need to add target_metadata to the offline migration context manually. fixes #189 --- diff --git a/alembic/templates/generic/env.py b/alembic/templates/generic/env.py index f72400b1..712b6164 100644 --- a/alembic/templates/generic/env.py +++ b/alembic/templates/generic/env.py @@ -35,7 +35,7 @@ def run_migrations_offline(): """ url = config.get_main_option("sqlalchemy.url") - context.configure(url=url) + context.configure(url=url, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations() diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py index a9cd3934..e3511de9 100644 --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@ -65,7 +65,8 @@ def run_migrations_offline(): file_ = "%s.sql" % name logger.info("Writing output to %s" % file_) with open(file_, 'w') as buffer: - context.configure(url=rec['url'], output_buffer=buffer) + context.configure(url=rec['url'], output_buffer=buffer, + target_metadata=target_metadata.get(name)) with context.begin_transaction(): context.run_migrations(engine_name=name) diff --git a/alembic/templates/pylons/env.py b/alembic/templates/pylons/env.py index 7cc35d4a..36c3fca9 100644 --- a/alembic/templates/pylons/env.py +++ b/alembic/templates/pylons/env.py @@ -46,7 +46,7 @@ def run_migrations_offline(): """ context.configure( - url=meta.engine.url) + url=meta.engine.url, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations()