]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- ensure that target_metadata is also present in the offline migration context,
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Mar 2014 14:17:37 +0000 (10:17 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Mar 2014 14:17:37 +0000 (10:17 -0400)
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

alembic/templates/generic/env.py
alembic/templates/multidb/env.py
alembic/templates/pylons/env.py

index f72400b1078101ea758b0e655b5076476f1d0bd0..712b6164d5473af54d79987efcf993486b12c310 100644 (file)
@@ -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()
index a9cd3934db76064b5a819a599553785bb982036a..e3511de9c41cdc2f329a9805090755ed5c5b779e 100644 (file)
@@ -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)
 
index 7cc35d4a62f3acb232c7c112ffece3988cc4da0b..36c3fca96b07e6fcdcbdd6190f9119568deb234b 100644 (file)
@@ -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()