MP023WARNINGAuto-fixableFree
require-if-not-exists
What It Detects
CREATE TABLE/INDEX without IF NOT EXISTS fails if the object already exists.
Why It's Dangerous
Without IF NOT EXISTS, re-running a migration fails with "relation already exists". Idempotent migrations are safer for retry and rollback scenarios.
Bad Example
CREATE TABLE users (id BIGINT PRIMARY KEY);
Good Example
CREATE TABLE IF NOT EXISTS users (id BIGINT PRIMARY KEY);
Auto-fix
Run migrationpilot analyze file.sql --fix to automatically fix this violation.
Configuration
Disable this rule:
# .migrationpilotrc.yml rules: MP023: false
Or change its severity:
# .migrationpilotrc.yml
rules:
MP023:
severity: warning