MP031CRITICALFree

ban-exclusion-constraint

What It Detects

EXCLUSION constraints build a GiST index under ACCESS EXCLUSIVE lock.

Why It's Dangerous

Adding an exclusion constraint creates a GiST index and validates all existing rows while holding ACCESS EXCLUSIVE. This can take a long time on large tables.

Bad Example

ALTER TABLE bookings ADD CONSTRAINT no_overlap
  EXCLUDE USING gist (room WITH =, during WITH &&);

Good Example

-- Consider application-level validation or
-- schedule during maintenance window

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP031: false

Or change its severity:

# .migrationpilotrc.yml
rules:
  MP031:
    severity: warning