From 63392b338531ed4ca7f0ab62fb618051235d80c1 Mon Sep 17 00:00:00 2001 From: Surya Kant Bansal Date: Fri, 2 Oct 2020 13:03:20 +0530 Subject: [PATCH] fix: update db url --- migrations/env.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index 05123ef..ea564ab 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,9 +1,8 @@ -import os - from alembic import context from logging.config import fileConfig from sqlalchemy import engine_from_config, pool +from app.core import settings from app.database.base import Base # this is the Alembic Config object, which provides @@ -25,10 +24,6 @@ # ... etc. -def get_url(): - return os.getenv("DATABASE_URL", "postgresql://localhost:5432/fastapi_db") - - def run_migrations_offline(): """Run migrations in 'offline' mode. @@ -41,7 +36,7 @@ def run_migrations_offline(): script output. """ - url = get_url() + url = settings.SQLALCHEMY_DATABASE_URI context.configure(url=url, target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}, compare_type=True) @@ -57,7 +52,7 @@ def run_migrations_online(): """ configuration = config.get_section(config.config_ini_section) - configuration["sqlalchemy.url"] = get_url() + configuration["sqlalchemy.url"] = settings.SQLALCHEMY_DATABASE_URI connectable = engine_from_config(configuration, prefix="sqlalchemy.", poolclass=pool.NullPool) with connectable.connect() as connection: