feat: add migration runner and wire into create_app
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-1
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user