From 224da9fff8bf518838a6700562e33f6cdbc9175b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Jan 2021 10:20:15 +0100 Subject: [PATCH] try to find heroku problem :wrench: --- migrations/env.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index 9452179..e486088 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -23,8 +23,8 @@ logger = logging.getLogger('alembic.env') # target_metadata = mymodel.Base.metadata from flask import current_app 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 # 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(): """Run migrations in 'offline' mode. - This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. - Calls to context.execute() here emit the given string to the script output. - """ url = config.get_main_option("sqlalchemy.url") context.configure( @@ -56,10 +53,8 @@ def run_migrations_offline(): def run_migrations_online(): """Run migrations in 'online' mode. - In this scenario we need to create an Engine and associate a connection with the context. - """ # this callback is used to prevent an auto-migration from being generated @@ -93,4 +88,4 @@ def run_migrations_online(): if context.is_offline_mode(): run_migrations_offline() else: - run_migrations_online() + run_migrations_online() \ No newline at end of file