Migrate poo recorder and align Alembic naming
This commit is contained in:
+15
@@ -8,8 +8,10 @@ from app import models # noqa: F401
|
||||
from app.api.routes import pages, status
|
||||
from app.api.routes.homeassistant import router as homeassistant_router
|
||||
from app.api.routes.location import router as location_router
|
||||
from app.api.routes.poo import router as poo_router
|
||||
from app.config import get_settings
|
||||
from scripts.location_db_adopt import LocationDatabaseAdoptionError, validate_location_runtime_db
|
||||
from scripts.poo_db_adopt import PooDatabaseAdoptionError, validate_poo_runtime_db
|
||||
|
||||
|
||||
def ensure_location_db_ready() -> None:
|
||||
@@ -23,6 +25,17 @@ def ensure_location_db_ready() -> None:
|
||||
raise RuntimeError(str(exc)) from exc
|
||||
|
||||
|
||||
def ensure_poo_db_ready() -> None:
|
||||
settings = get_settings()
|
||||
if settings.poo_sqlite_path is None:
|
||||
return
|
||||
|
||||
try:
|
||||
validate_poo_runtime_db(settings.poo_database_url)
|
||||
except PooDatabaseAdoptionError as exc:
|
||||
raise RuntimeError(str(exc)) from exc
|
||||
|
||||
|
||||
def ensure_runtime_dirs() -> None:
|
||||
settings = get_settings()
|
||||
for path in (settings.location_sqlite_path, settings.poo_sqlite_path):
|
||||
@@ -34,6 +47,7 @@ def ensure_runtime_dirs() -> None:
|
||||
async def lifespan(_: FastAPI):
|
||||
ensure_runtime_dirs()
|
||||
ensure_location_db_ready()
|
||||
ensure_poo_db_ready()
|
||||
yield
|
||||
|
||||
|
||||
@@ -57,6 +71,7 @@ def create_app() -> FastAPI:
|
||||
app.include_router(pages.router)
|
||||
app.include_router(homeassistant_router)
|
||||
app.include_router(location_router)
|
||||
app.include_router(poo_router)
|
||||
return app
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user