更新docker构建cd (#10)
* update github actions * update github actions * update github actions * update github actions * update github actions * update github actions * update github actions --------- Co-authored-by: Kevin <kevin@brighteng.org>
This commit is contained in:
@@ -22,13 +22,27 @@ load_dotenv()
|
||||
import psycopg
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.engine import Engine
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_engine() -> Engine:
|
||||
url = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@localhost:5432/life_echo")
|
||||
migration_url = os.getenv("MIGRATION_DATABASE_URL")
|
||||
database_url = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@localhost:5432/life_echo")
|
||||
url = migration_url or database_url
|
||||
# region agent log
|
||||
logger.info(
|
||||
"DEBUG migration env selection: migration_present=%s database_present=%s selected=%s selected_host=%s migration_host=%s database_host=%s",
|
||||
bool(migration_url),
|
||||
bool(database_url),
|
||||
"MIGRATION_DATABASE_URL" if migration_url else "DATABASE_URL",
|
||||
urlsplit(url).hostname or "<missing-host>",
|
||||
urlsplit(migration_url).hostname if migration_url else "<empty>",
|
||||
urlsplit(database_url).hostname or "<missing-host>",
|
||||
)
|
||||
# endregion agent log
|
||||
return create_engine(url.replace("postgresql://", "postgresql+psycopg://"), pool_pre_ping=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user