MP018WARNINGFree
no-force-set-not-null
What It Detects
SET NOT NULL without CHECK constraint pre-validation scans the entire table.
Why It's Dangerous
SET NOT NULL requires scanning every row to verify no NULLs exist, all under ACCESS EXCLUSIVE. Pre-validate with a CHECK constraint using NOT VALID, then the SET NOT NULL is instant.
Bad Example
ALTER TABLE users ALTER COLUMN email SET NOT NULL;
Good Example
ALTER TABLE users ADD CONSTRAINT chk_email_nn CHECK (email IS NOT NULL) NOT VALID; ALTER TABLE users VALIDATE CONSTRAINT chk_email_nn; ALTER TABLE users ALTER COLUMN email SET NOT NULL;
Configuration
Disable this rule:
# .migrationpilotrc.yml rules: MP018: false
Or change its severity:
# .migrationpilotrc.yml
rules:
MP018:
severity: warning