diff --git a/migrations/env.py b/migrations/env.py index 9bab402..2147056 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -29,6 +29,8 @@ # my_important_option = config.get_main_option("my_important_option") # ... etc. +url = os.getenv("DATABASE_URL") + def run_migrations_offline() -> None: """Run migrations in 'offline' mode. @@ -42,7 +44,7 @@ def run_migrations_offline() -> None: script output. """ - url = os.getenv("DATABASE_URL") + context.configure( url=url, target_metadata=target_metadata, @@ -61,8 +63,9 @@ def run_migrations_online() -> None: and associate a connection with the context. """ + connectable = engine_from_config( - config.get_section(config.config_ini_section, {}), + config.get_section(config.config_ini_section, {"url": url}), prefix="sqlalchemy.", poolclass=pool.NullPool, )