fix(db): prefer postgres config in production refs NOISSUE

This commit is contained in:
2026-04-10 20:37:31 +02:00
parent a357a307a7
commit 59a7e9787e
5 changed files with 89 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ The NiceGUI frontend provides:
from __future__ import annotations
from contextlib import asynccontextmanager
import json
import re
from pathlib import Path
@@ -42,7 +43,18 @@ except ImportError:
__version__ = "0.0.1"
app = FastAPI()
@asynccontextmanager
async def lifespan(_app: FastAPI):
"""Log resolved runtime configuration when the app starts."""
runtime = database_module.get_database_runtime_summary()
print(
f"Runtime configuration: database_backend={runtime['backend']} target={runtime['target']}"
)
yield
app = FastAPI(lifespan=lifespan)
DbSession = Annotated[Session, Depends(database_module.get_db)]
PROJECT_ID_PATTERN = re.compile(r"[^a-z0-9]+")
@@ -180,7 +192,7 @@ def health_check():
"""Health check endpoint."""
return {
'status': 'healthy',
'database': 'sqlite' if database_module.settings.USE_SQLITE else 'postgresql',
'database': 'sqlite' if database_module.settings.use_sqlite else 'postgresql',
}