from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def test_responsibility_migration_is_audited_and_data_preserving(): migration = ( ROOT / "migrations" / "versions" / "20260729_270_governance_responsibilities.py" ).read_text(encoding="utf-8") assert 'revision = "20260729_270"' in migration assert 'down_revision = "20260724_260"' in migration for table in ( "governance_responsibility_scopes", "governance_responsibility_assignments", "governance_responsibility_audit_events", ): assert f"CREATE TABLE IF NOT EXISTS public.{table}" in migration assert "responsibility_role" in migration assert "raci_role" in migration assert "before_state JSONB" in migration assert "after_state JSONB" in migration assert "DROP TABLE" not in migration.upper()