|
|
@ -14,17 +14,19 @@ config = context.config |
|
|
|
# Interpret the config file for Python logging. |
|
|
|
# This line sets up loggers basically. |
|
|
|
fileConfig(config.config_file_name) |
|
|
|
logger = logging.getLogger('alembic.env') |
|
|
|
logger = logging.getLogger("alembic.env") |
|
|
|
|
|
|
|
# add your model's MetaData object here |
|
|
|
# for 'autogenerate' support |
|
|
|
# from myapp import mymodel |
|
|
|
# target_metadata = mymodel.Base.metadata |
|
|
|
config.set_main_option( |
|
|
|
'sqlalchemy.url', |
|
|
|
str(current_app.extensions['migrate'].db.get_engine().url).replace( |
|
|
|
'%', '%%')) |
|
|
|
target_metadata = current_app.extensions['migrate'].db.metadata |
|
|
|
"sqlalchemy.url", |
|
|
|
str(current_app.extensions["migrate"].db.get_engine().url).replace( |
|
|
|
"%", "%%" |
|
|
|
), |
|
|
|
) |
|
|
|
target_metadata = current_app.extensions["migrate"].db.metadata |
|
|
|
|
|
|
|
# other values from the config, defined by the needs of env.py, |
|
|
|
# can be acquired: |
|
|
@ -65,20 +67,20 @@ def run_migrations_online(): |
|
|
|
# when there are no changes to the schema |
|
|
|
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html |
|
|
|
def process_revision_directives(context, revision, directives): |
|
|
|
if getattr(config.cmd_opts, 'autogenerate', False): |
|
|
|
if getattr(config.cmd_opts, "autogenerate", False): |
|
|
|
script = directives[0] |
|
|
|
if script.upgrade_ops.is_empty(): |
|
|
|
directives[:] = [] |
|
|
|
logger.info('No changes in schema detected.') |
|
|
|
logger.info("No changes in schema detected.") |
|
|
|
|
|
|
|
connectable = current_app.extensions['migrate'].db.get_engine() |
|
|
|
connectable = current_app.extensions["migrate"].db.get_engine() |
|
|
|
|
|
|
|
with connectable.connect() as connection: |
|
|
|
context.configure( |
|
|
|
connection=connection, |
|
|
|
target_metadata=target_metadata, |
|
|
|
process_revision_directives=process_revision_directives, |
|
|
|
**current_app.extensions['migrate'].configure_args |
|
|
|
**current_app.extensions["migrate"].configure_args, |
|
|
|
) |
|
|
|
|
|
|
|
with context.begin_transaction(): |
|
|
|