fix: load numbered migration module dynamically
This commit is contained in:
@@ -23,10 +23,12 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
|
||||
async def init_db():
|
||||
"""Apply non-destructive schema upgrades before creating missing tables."""
|
||||
from importlib import import_module
|
||||
|
||||
from app.models import Base
|
||||
from migrations.versions.20260803_reliability_monitoring import (
|
||||
run_reliability_migration,
|
||||
)
|
||||
|
||||
migration = import_module("migrations.versions.20260803_reliability_monitoring")
|
||||
run_reliability_migration = migration.run_reliability_migration
|
||||
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(run_reliability_migration)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
"""Regression coverage for application dependency module imports."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_dependency_module_compiles():
|
||||
"""Database initialization dependencies remain valid Python syntax."""
|
||||
module_path = Path(__file__).parents[1] / "app" / "core" / "deps.py"
|
||||
|
||||
compile(module_path.read_text(encoding="utf-8"), str(module_path), "exec")
|
||||
Reference in New Issue
Block a user