MP082WARNINGFree

warn-not-enforced-constraint

What It Detects

NOT ENFORCED constraint will not enforce data integrity. Invalid data can be inserted.

Why It's Dangerous

PostgreSQL 18 NOT ENFORCED constraints exist only as metadata hints for the query planner. The database will NOT reject invalid data. Useful for documentation or gradual migration, but dangerous if you expect enforcement.

Bad Example

ALTER TABLE orders ADD CONSTRAINT fk_user
  FOREIGN KEY (user_id) REFERENCES users(id) NOT ENFORCED;
-- Invalid user_id values will NOT be rejected!

Good Example

-- If you need enforcement:
ALTER TABLE orders ADD CONSTRAINT fk_user
  FOREIGN KEY (user_id) REFERENCES users(id) NOT VALID;
ALTER TABLE orders VALIDATE CONSTRAINT fk_user;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP082: false

Or change its severity:

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