All rules Rule BV010
warning
free in the CLI

DROP with CASCADE hitting unexpected dependents

Warning — this works, but blocks traffic or rewrites data at scale.

What it catches

CASCADE resolves the dependency graph at execution time and drops everything in it, without listing what it took. What it removes in production can differ from dev — a view or foreign key added since, gone silently.

Fires on

DROP TABLE legacy_events CASCADE;

Do this instead

Run the DROP without CASCADE first: it fails and lists every dependent object. Then drop each dependent explicitly in the migration, so the blast radius is written down and reviewed instead of resolved silently at execution time.

-- DROP ... RESTRICT (the default) fails and names every dependent;
-- drop them explicitly so the migration says what it removes:
SET lock_timeout = '5s';
DROP VIEW legacy_events_summary;
-- then, once nothing references it (see BV005/BV030):
--    DROP TABLE legacy_events;
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