feat: add migration runner and wire into create_app

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 21:12:06 -04:00
parent 763cbda3ac
commit 415fe7eba9
2 changed files with 69 additions and 1 deletions
+15 -1
View File
@@ -35,11 +35,20 @@ def create_app(
from unittest.mock import MagicMock
app.db_sessionmaker = MagicMock()
# Run migrations (core + plugin) synchronously before event loop starts
if not testing:
from .core.migration_runner import run_migrations, get_plugin_migration_dirs
_plugin_dir = Path(app.config["PLUGIN_DIR"])
_plugin_migration_dirs = get_plugin_migration_dirs(
_plugin_dir, app.config["PLUGINS"]
)
run_migrations(app.config["DATABASE_URL"], _plugin_migration_dirs)
# Alert pipeline
from .core.alerts import init_alerts
init_alerts(app)
# Register blueprints
# Register core blueprints
from .auth.routes import auth_bp
from .dashboard.routes import dashboard_bp
from .hosts.routes import hosts_bp
@@ -58,6 +67,11 @@ def create_app(
if not testing:
_register_core_tasks(app, cfg)
# Load plugins
if not testing:
from .core.plugin_manager import load_plugins
load_plugins(app)
# Health check
@app.get("/health")
async def health():