"""Models and Alembic history must describe the same schema — the `alembic check` of this project. `migrated` upgrades a throwaway database to head, so a model change committed without its revision shows up here as a non-empty diff.""" from __future__ import annotations from alembic.autogenerate import compare_metadata from alembic.migration import MigrationContext async def test_migrations_match_the_models(migrated: str): import fintracker.models # noqa: F401 — registers every table on Base.metadata from fintracker.db import get_engine from fintracker.db.base import Base async with get_engine().connect() as conn: diff = await conn.run_sync( lambda c: compare_metadata(MigrationContext.configure(c), Base.metadata) ) assert diff == [], f"models changed without a migration (run `just revision`): {diff}"