diff options
author | Bryce Lohr <bryce.lohr@gmail.com> | 2012-04-25 22:12:34 -0400 |
---|---|---|
committer | Bryce Lohr <bryce.lohr@gmail.com> | 2012-04-25 22:12:34 -0400 |
commit | 9fa2dd94dd73846ee57b9a2ca93e68347a0e0df7 (patch) | |
tree | b9aee00ab6e5b028140209f7a3fe00fa93947bdb /alembic/templates | |
parent | 2747894d2c5212e718a2631eb4984b55074f710a (diff) | |
download | alembic-9fa2dd94dd73846ee57b9a2ca93e68347a0e0df7.tar.gz |
Updated multidb template's env.py to be closer to generic's. Fixed invalid reference to options, fixed SQL comment to be MySQL-safe
Diffstat (limited to 'alembic/templates')
-rw-r--r-- | alembic/templates/multidb/env.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py index 8812294..e0ebbc1 100644 --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@ -1,17 +1,24 @@ -USE_TWOPHASE = False - +from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool +from logging.config import fileConfig import re import sys -import logging -logging.fileConfig(options.config_file) +USE_TWOPHASE = False + +# this is the Alembic Config object, which provides +# access to the values within the .ini file in use. +config = context.config + +# Interpret the config file for Python logging. +# This line sets up loggers basically. +fileConfig(config.config_file_name) # gather section names referring to different # databases. These are named "engine1", "engine2" # in the sample .ini file. -db_names = options.get_main_option('databases') +db_names = config.get_main_option('databases') # add your model's MetaData objects here # for 'autogenerate' support. These must be set @@ -26,6 +33,11 @@ db_names = options.get_main_option('databases') #} target_metadata = {} +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + def run_migrations_offline(): """Run migrations in 'offline' mode. @@ -93,7 +105,7 @@ def run_migrations_online(): downgrade_token="%s_downgrades", target_metadata=target_metadata.get(name) ) - context.execute("--running migrations for engine %s" % name) + context.execute("-- running migrations for engine %s" % name) context.run_migrations(engine=name) if USE_TWOPHASE: |