fix: address code review feedback - use specific exceptions, dynamic revision IDs in tests

- Replace bare Exception catches with sa.exc.OperationalError in migration 007
- Use ScriptDirectory.get_heads() for dynamic revision ID assertions in tests
- Make migration count assertion flexible (>= 8 instead of == 8)
- Rewrite pending migrations test to actually test upgrade from revision 006

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-01 16:57:19 +00:00
parent 87d1b9d935
commit 8d81ed6c74
3 changed files with 113 additions and 19 deletions
@@ -29,11 +29,11 @@ def upgrade() -> None:
# The filehash column retains a non-unique index for lookups.
try:
op.drop_index("ix_files_filehash", table_name="files")
except Exception as exc:
except sa.exc.OperationalError as exc:
logger.debug("Could not drop ix_files_filehash (may not exist): %s", exc)
try:
op.create_index("ix_files_filehash", "files", ["filehash"], unique=False)
except Exception as exc:
except sa.exc.OperationalError as exc:
logger.debug("Could not create ix_files_filehash (may already exist): %s", exc)