-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,17 @@ | |
fileConfig(config.config_file_name) | ||
logger = logging.getLogger('alembic.env') | ||
|
||
|
||
def get_engine(bind_key=None): | ||
try: | ||
# this works with Flask-SQLAlchemy>=3 | ||
return current_app.extensions['migrate'].db.get_engine( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
miguelgrinberg
Author
Owner
|
||
bind_key=bind_key) | ||
except TypeError: | ||
# this works with Flask-SQLAlchemy<3 | ||
return current_app.extensions['migrate'].db.get_engine(bind=bind_key) | ||
|
||
|
||
# add your model's MetaData object here | ||
# for 'autogenerate' support | ||
# from myapp import mymodel | ||
|
@@ -38,8 +49,7 @@ | |
for bind in bind_names: | ||
context.config.set_section_option( | ||
bind, "sqlalchemy.url", | ||
str(current_app.extensions['migrate'].db.get_engine( | ||
bind=bind).url).replace('%', '%%')) | ||
str(get_engine(bind_key=bind).url).replace('%', '%%')) | ||
target_db = current_app.extensions['migrate'].db | ||
|
||
# other values from the config, defined by the needs of env.py, | ||
|
@@ -132,8 +142,7 @@ def process_revision_directives(context, revision, directives): | |
} | ||
for name in bind_names: | ||
engines[name] = rec = {} | ||
rec['engine'] = current_app.extensions['migrate'].db.get_engine( | ||
bind=name) | ||
rec['engine'] = get_engine(bind_key=name) | ||
|
||
for name, rec in engines.items(): | ||
engine = rec['engine'] | ||
|
db.get_engine
was deprecated in Flask-SQLAlchemy 3. Usedb.engines[bind_key]
.