MP037WARNINGAuto-fixableFree

prefer-text-over-varchar

What It Detects

VARCHAR(n) has no performance benefit over TEXT in PostgreSQL.

Why It's Dangerous

In PostgreSQL, VARCHAR(n) and TEXT use the same storage. The length constraint adds overhead without benefit. Use TEXT with a CHECK constraint if you need length validation.

Bad Example

ALTER TABLE users ADD COLUMN bio VARCHAR(500);

Good Example

ALTER TABLE users ADD COLUMN bio TEXT;
-- If length validation needed:
ALTER TABLE users ADD CONSTRAINT chk_bio_len CHECK (length(bio) <= 500) NOT VALID;

Auto-fix

Run migrationpilot analyze file.sql --fix to automatically fix this violation.

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP037: false

Or change its severity:

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