fix: auto-migrate SQLite schema to reconcile newly added columns on startup
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user