Skip to content

Commit

Permalink
fix: update db url
Browse files Browse the repository at this point in the history
  • Loading branch information
skb1129 committed Oct 2, 2020
1 parent 9a63a33 commit 63392b3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions migrations/env.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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)

Expand All @@ -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:
Expand Down

0 comments on commit 63392b3

Please sign in to comment.