All rules Rule BV001
critical
tier 2 — needs a live schema
free in the CLI

DROP COLUMN with live foreign-key references

Critical — this fails outright or takes production down.

What it catches

Dropping a column that other tables' foreign keys point at either fails mid-migration or, with CASCADE, silently drops those constraints — leaving orphanable rows in dependent tables.

Fires on

ALTER TABLE users DROP COLUMN id;

Do this instead

Remove each dependent foreign key explicitly first — one reviewed, lock_timeout-guarded migration per referencing table — so nothing is dropped implicitly. Only drop the column itself a release after app code stopped reading it.

-- 1. Drop each referencing FK explicitly (repeat per dependent table):
SET lock_timeout = '5s';
ALTER TABLE orders DROP CONSTRAINT orders_user_id_fkey;
-- 2. A release later, once nothing reads the column:
--    ALTER TABLE users DROP COLUMN legacy_id;
Catch this before it ships

This rule runs locally in the free CLI — or with the full corpus through the hosted service: npx bolvrk check migration.sql