Skip to content

Conversation

@webjunkie
Copy link
Contributor

Changes

Update migration analyzer to flag DROP CONSTRAINT operations as score 2 (needs review) instead of score 1 (safe).

While DROP CONSTRAINT is technically instant (no table lock), it can break running code during rolling deployments. The analyzer should flag these for human review rather than auto-approving them.

What changed

  • operations.py: Changed DROP CONSTRAINT from score 1 → 2
  • Added deployment safety guidance with common scenarios:
    • Dropping UNIQUE constraints: ensure code handles duplicates
    • Dropping FOREIGN KEY constraints: ensure code doesn't assume referential integrity
    • Replacing constraints: add new → deploy → wait → drop old
  • Updated test expectations (score 1 → 2, SAFE → NEEDS_REVIEW)

Test plan

  • All 65 tests pass
  • Updated test_run_sql_drop_constraint to expect score 2
…review

Change DROP CONSTRAINT from score 1 (safe) to score 2 (needs review) to catch
deployment safety issues. While the operation is instant (no table lock), dropping
constraints can break running code during rolling deployments.

Adds guidance about safe patterns: verify no code relies on constraint, deploy
new constraints before dropping old ones, wait one deployment cycle. Aligns with
existing patterns for dropping columns/tables and addresses scenarios like
dropping UNIQUE constraints where code may not handle duplicates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants