Fix alembic migrations for kube
This commit is contained in:
parent
144ed63381
commit
0ae93db617
@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
@ -7,10 +5,12 @@ from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
from mev_inspect.db import get_sqlalchemy_database_uri
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
config.set_main_option("sqlalchemy.url", os.environ["SQLALCHEMY_DATABASE_URI"])
|
||||
config.set_main_option("sqlalchemy.url", get_sqlalchemy_database_uri())
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
|
@ -4,13 +4,16 @@ from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
|
||||
def get_engine():
|
||||
def get_sqlalchemy_database_uri():
|
||||
username = os.getenv("POSTGRES_USER")
|
||||
password = os.getenv("POSTGRES_PASSWORD")
|
||||
server = "postgresql"
|
||||
db_name = "mev_inspect"
|
||||
uri = f"postgresql://{username}:{password}@{server}/{db_name}"
|
||||
return create_engine(uri)
|
||||
return f"postgresql://{username}:{password}@{server}/{db_name}"
|
||||
|
||||
|
||||
def get_engine():
|
||||
return create_engine(get_sqlalchemy_database_uri())
|
||||
|
||||
|
||||
def get_session():
|
||||
|
Loading…
x
Reference in New Issue
Block a user