MP044WARNINGFree

no-data-loss-type-narrowing

What It Detects

Narrowing a column type (e.g., BIGINT to INT, TEXT to VARCHAR) risks data loss.

Why It's Dangerous

Narrowing a column type truncates or rejects values that exceed the new type bounds. This causes data loss and requires a full table rewrite under ACCESS EXCLUSIVE.

Bad Example

ALTER TABLE users ALTER COLUMN age TYPE SMALLINT;

Good Example

-- Verify no data exceeds new bounds first:
SELECT count(*) FROM users WHERE age > 32767;
-- Then alter with explicit cast
ALTER TABLE users ALTER COLUMN age TYPE SMALLINT;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP044: false

Or change its severity:

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