MP048WARNINGFree

ban-alter-default-volatile

What It Detects

Setting a volatile DEFAULT (now(), random()) on an existing column does not update existing rows.

Why It's Dangerous

ALTER TABLE ALTER COLUMN SET DEFAULT only affects future INSERTs. Existing rows are NOT updated. Using a volatile function like now() may give the false impression that existing NULLs will be filled.

Bad Example

ALTER TABLE users ALTER COLUMN created_at SET DEFAULT now();
-- Existing rows with NULL remain NULL!

Good Example

ALTER TABLE users ALTER COLUMN created_at SET DEFAULT now();
-- Backfill existing rows explicitly:
UPDATE users SET created_at = now() WHERE created_at IS NULL;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP048: false

Or change its severity:

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