R006 · default CAUTION

DROP COLUMN

DROP COLUMN is metadata-fast in Postgres, but app code referencing the column will break the moment the migration runs.

Why this is a problem

This is a deploy ordering risk, not a lock risk. If app instances are still reading/writing the column when the migration runs, every request to those instances errors. The fix is two-phase deploy.

Don't do this

-- Single migration: app may still reference 'old_status'
ALTER TABLE orders DROP COLUMN old_status;

Do this instead

-- Migration N (deploy first): update app code to stop using old_status
--   No DB migration. Wait for full app rollout.

-- Migration N+1 (deploy after): now safe to drop
ALTER TABLE orders DROP COLUMN old_status;

References

Catch this rule on every PR.

dbivio runs all 10 rules automatically with your real Postgres stats. Install once, get a verdict on every migration PR.

Install on GitHub