"""Initial schema migration — creates all tables. This is a hand-rolled async migration that creates all tables defined in `app.models` via SQLAlchemy `Base.metadata.create_all`. It is the equivalent of alembic migration 001. For real-world deployments the project includes an `alembic.ini` and `alembic env.py` so that incremental migrations can be added — but for the MVP we use this single idempotent script. """ from __future__ import annotations from sqlalchemy.ext.asyncio import AsyncEngine from app.db import Base from app.models import * # noqa: F401,F403 — ensure all models are imported async def create_all_tables(engine: AsyncEngine) -> None: """Create all tables defined on Base.metadata. Idempotent.""" async with engine.begin() as conn: await conn.run_sync(Base.metadata.create_all) async def drop_all_tables(engine: AsyncEngine) -> None: """Drop all tables. Used in tests.""" async with engine.begin() as conn: await conn.run_sync(Base.metadata.drop_all)