Integrate data migration into FastAPI lifespan (Task 3)

This commit is contained in:
2025-12-01 18:16:54 +01:00
parent de58161014
commit 148e6c1b58
3 changed files with 233 additions and 1 deletions

View File

@@ -67,6 +67,23 @@ async def lifespan(app: FastAPI):
except Exception as e:
logger.warning("Failed to load config from config.json: %s", e)
# Run data file to database migration
try:
from src.server.services.startup_migration import (
ensure_migration_on_startup,
)
migration_result = await ensure_migration_on_startup()
if migration_result:
logger.info(
"Data migration complete: %d migrated, %d skipped, %d failed",
migration_result.migrated,
migration_result.skipped,
migration_result.failed
)
except Exception as e:
logger.error("Data migration failed: %s", e, exc_info=True)
# Continue startup - migration failure should not block app
# Initialize progress service with event subscription
progress_service = get_progress_service()
ws_service = get_websocket_service()