fix: auto-migrate SQLite schema to reconcile newly added columns on startup

This commit is contained in:
Atharv1705
2026-11-13 18:43:37 +05:30
parent d9ca4bbb02
commit 640ae9c1b4
6 changed files with 82 additions and 0 deletions
+2
View File
@@ -11,6 +11,7 @@ from fastapi.responses import JSONResponse
from .core.config import settings as app_settings
from .core.db import SessionLocal, engine, get_scheduler_db
from .core.exceptions import CodedHTTPException, coded_http_exception_handler
from .core.migrations import run_sqlite_migrations
from .models import Base
from .routers import (
assets,
@@ -56,6 +57,7 @@ def _scheduled_alert_job() -> None:
@asynccontextmanager
async def lifespan(app: FastAPI):
Base.metadata.create_all(bind=engine)
run_sqlite_migrations(engine)
with SessionLocal() as db:
ensure_default_settings(db)
db.commit()