Catch migration exceptions so app doesn't crash-loop on startup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martin Hohenberg
2026-06-18 21:37:02 +02:00
parent a4010c63a2
commit 541bb88847

View File

@@ -15,7 +15,10 @@ async def lifespan(app: FastAPI):
ok, msg = check_db()
if ok:
logger.info("Database connection OK")
run_migrations()
try:
run_migrations()
except Exception:
logger.exception("Migration failed — app will start but DB schema may be out of date")
else:
logger.warning("Database unreachable: %s", msg)
yield