🔧 Reuse database url from config in alembic setup (#1229)
This commit is contained in:
@@ -19,6 +19,7 @@ fileConfig(config.config_file_name)
|
||||
# target_metadata = None
|
||||
|
||||
from app.models import SQLModel # noqa
|
||||
from app.core.config import settings # noqa
|
||||
|
||||
target_metadata = SQLModel.metadata
|
||||
|
||||
@@ -29,12 +30,7 @@ target_metadata = SQLModel.metadata
|
||||
|
||||
|
||||
def get_url():
|
||||
user = os.getenv("POSTGRES_USER", "postgres")
|
||||
password = os.getenv("POSTGRES_PASSWORD", "")
|
||||
server = os.getenv("POSTGRES_SERVER", "db")
|
||||
port = os.getenv("POSTGRES_PORT", "5432")
|
||||
db = os.getenv("POSTGRES_DB", "app")
|
||||
return f"postgresql+psycopg://{user}:{password}@{server}:{port}/{db}"
|
||||
return str(settings.SQLALCHEMY_DATABASE_URI)
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
|
Reference in New Issue
Block a user