diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-14 10:17:37 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-14 10:17:37 -0400 |
commit | efdf9e408fb10049de5effd3dade6fa276190c4b (patch) | |
tree | e48b75b7822c43499b2aa5987366d9849e3828a5 /alembic | |
parent | 4bb4d50b8ace9ca17bf4239c584e6afae83d6fbc (diff) | |
download | alembic-efdf9e408fb10049de5effd3dade6fa276190c4b.tar.gz |
- 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
Diffstat (limited to 'alembic')
-rw-r--r-- | alembic/templates/generic/env.py | 2 | ||||
-rw-r--r-- | alembic/templates/multidb/env.py | 3 | ||||
-rw-r--r-- | alembic/templates/pylons/env.py | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/alembic/templates/generic/env.py b/alembic/templates/generic/env.py index f72400b..712b616 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 a9cd393..e3511de 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 7cc35d4..36c3fca 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() |