|
|
@ -23,8 +23,8 @@ logger = logging.getLogger('alembic.env') |
|
|
# target_metadata = mymodel.Base.metadata |
|
|
# target_metadata = mymodel.Base.metadata |
|
|
from flask import current_app |
|
|
from flask import current_app |
|
|
config.set_main_option( |
|
|
config.set_main_option( |
|
|
'sqlalchemy.url', |
|
|
|
|
|
str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%')) |
|
|
|
|
|
|
|
|
'sqlalchemy.url', current_app.config.get( |
|
|
|
|
|
'SQLALCHEMY_DATABASE_URI').replace('%', '%%')) |
|
|
target_metadata = current_app.extensions['migrate'].db.metadata |
|
|
target_metadata = current_app.extensions['migrate'].db.metadata |
|
|
|
|
|
|
|
|
# other values from the config, defined by the needs of env.py, |
|
|
# other values from the config, defined by the needs of env.py, |
|
|
@ -35,15 +35,12 @@ target_metadata = current_app.extensions['migrate'].db.metadata |
|
|
|
|
|
|
|
|
def run_migrations_offline(): |
|
|
def run_migrations_offline(): |
|
|
"""Run migrations in 'offline' mode. |
|
|
"""Run migrations in 'offline' mode. |
|
|
|
|
|
|
|
|
This configures the context with just a URL |
|
|
This configures the context with just a URL |
|
|
and not an Engine, though an Engine is acceptable |
|
|
and not an Engine, though an Engine is acceptable |
|
|
here as well. By skipping the Engine creation |
|
|
here as well. By skipping the Engine creation |
|
|
we don't even need a DBAPI to be available. |
|
|
we don't even need a DBAPI to be available. |
|
|
|
|
|
|
|
|
Calls to context.execute() here emit the given string to the |
|
|
Calls to context.execute() here emit the given string to the |
|
|
script output. |
|
|
script output. |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
url = config.get_main_option("sqlalchemy.url") |
|
|
url = config.get_main_option("sqlalchemy.url") |
|
|
context.configure( |
|
|
context.configure( |
|
|
@ -56,10 +53,8 @@ def run_migrations_offline(): |
|
|
|
|
|
|
|
|
def run_migrations_online(): |
|
|
def run_migrations_online(): |
|
|
"""Run migrations in 'online' mode. |
|
|
"""Run migrations in 'online' mode. |
|
|
|
|
|
|
|
|
In this scenario we need to create an Engine |
|
|
In this scenario we need to create an Engine |
|
|
and associate a connection with the context. |
|
|
and associate a connection with the context. |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
# this callback is used to prevent an auto-migration from being generated |
|
|
# this callback is used to prevent an auto-migration from being generated |
|
|
|