Files

21 lines
957 B
Python

"""Schema bootstrap: `create_all` on both databases at startup (ADR-003: no Alembic in the MVP).
The only module (besides registration code) that touches both schemas — and only their metadata.
"""
from app.db import audit as _audit # noqa: F401 (registers audit_log in clinical metadata)
from app.db import intake as _intake # noqa: F401
from app.db import max_notifications as _max_notifications # noqa: F401
from app.db import scheduler as _scheduler # noqa: F401
from app.db.clinical import ClinicalBase
from app.db.identity import IdentityBase
from app.db.session import clinical_engine, identity_engine
async def init_db() -> None:
"""Create missing tables in the identity and clinical databases. Idempotent."""
async with identity_engine().begin() as conn:
await conn.run_sync(IdentityBase.metadata.create_all)
async with clinical_engine().begin() as conn:
await conn.run_sync(ClinicalBase.metadata.create_all)