"""Migration tests for canonical Document metadata.""" from pathlib import Path from alembic import command from alembic.config import Config from sqlalchemy import create_engine, inspect def test_document_migration_matches_metadata(tmp_path: Path) -> None: project_root = Path(__file__).resolve().parents[2] database_path = tmp_path / "migration.sqlite3" database_url = f"sqlite+pysqlite:///{database_path}" config = Config(project_root / "alembic.ini") config.attributes["database_url"] = database_url command.upgrade(config, "head") command.check(config) inspector = inspect(create_engine(database_url)) assert "documents" in inspector.get_table_names() assert {column["name"] for column in inspector.get_columns("documents")} == { "id", "filename", "media_type", "size_bytes", "storage_key", "status", "error_message", "created_at", "updated_at", }