feat: Add CI workflow for running tests and update database URL handling
Some checks failed
Build and Push Docker Image / build-and-push (push) Successful in 1m8s
Deploy to Server / deploy (push) Failing after 2s
Run Tests / test (push) Failing after 9m32s

This commit is contained in:
2025-10-24 19:19:24 +02:00
parent 28fea1f3fe
commit f35607fedc
6 changed files with 28 additions and 18 deletions

View File

@@ -1,5 +1,4 @@
from sqlalchemy import create_engine
from sqlalchemy.engine import URL
from sqlalchemy.orm import declarative_base, sessionmaker
import os
from dotenv import load_dotenv
@@ -14,8 +13,8 @@ def _build_database_url() -> str:
Falls back to `DATABASE_URL` for backward compatibility.
"""
legacy_url = os.environ.get("DATABASE_URL")
if legacy_url:
legacy_url = os.environ.get("DATABASE_URL", "")
if legacy_url and legacy_url.strip() != "":
return legacy_url
driver = os.environ.get("DATABASE_DRIVER", "postgresql")
@@ -42,17 +41,12 @@ def _build_database_url() -> str:
f"granular variables ({', '.join(missing)})"
)
url = URL.create(
drivername=driver,
username=user,
password=password,
host=host,
port=int(port) if port else None,
database=database,
)
url = f"{driver}://{user}:{password}@{host}"
if port:
url += f":{port}"
url += f"/{database}"
if schema:
url = url.set(query={"options": f"-csearch_path={schema}"})
url += f"?options=-csearch_path={schema}"
return str(url)