MP074WARNINGFree

require-deferrable-fk

What It Detects

FK constraints should be DEFERRABLE to support safe bulk operations and avoid ordering issues.

Why It's Dangerous

Non-deferrable foreign keys are checked per-row during INSERT/UPDATE, requiring careful insertion order. DEFERRABLE constraints are checked at COMMIT time, allowing bulk inserts and circular references.

Bad Example

ALTER TABLE orders ADD CONSTRAINT fk_user
  FOREIGN KEY (user_id) REFERENCES users (id);

Good Example

ALTER TABLE orders ADD CONSTRAINT fk_user
  FOREIGN KEY (user_id) REFERENCES users (id)
  DEFERRABLE INITIALLY DEFERRED;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP074: false

Or change its severity:

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