MP052WARNINGFree

warn-dependent-objects

What It Detects

DROP COLUMN, RENAME COLUMN, or ALTER COLUMN TYPE may silently break views, functions, and triggers that reference the column.

Why It's Dangerous

Views, functions, and triggers that reference a column will fail at query time — not at migration time — when the column is dropped, renamed, or its type is changed. PostgreSQL does not automatically update these dependent objects.

Bad Example

ALTER TABLE users DROP COLUMN email;
-- Any view that SELECTs email will now fail at query time

Good Example

-- Check dependencies first:
SELECT dependent_ns.nspname || '.' || dependent_view.relname
FROM pg_depend
JOIN pg_rewrite ON pg_depend.objid = pg_rewrite.oid
JOIN pg_class AS dependent_view ON pg_rewrite.ev_class = dependent_view.oid
JOIN pg_namespace AS dependent_ns ON dependent_view.relnamespace = dependent_ns.oid
JOIN pg_class AS source_table ON pg_depend.refobjid = source_table.oid
JOIN pg_attribute ON pg_depend.refobjid = pg_attribute.attrelid
  AND pg_depend.refobjsubid = pg_attribute.attnum
WHERE source_table.relname = 'users'
  AND pg_attribute.attname = 'email';
-- Then drop only after confirming no dependents

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP052: false

Or change its severity:

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