Destructive Operations

DROP TABLE

Lock mode ACCESS EXCLUSIVE
Risk CRITICAL
Blocks reads, writes, other DDL
pgfence rule drop-table
DROP TABLE orders;

What this does

Irreversible data loss, and ACCESS EXCLUSIVE blocks every read and write on the table until it is gone.

Safe rewrite

Drop the table in a separate release after confirming no references remain

-- 1. Remove all application references to "orders".
-- 2. Deploy and verify in production.
-- 3. Drop in a follow-up migration after a confirmation period:
DROP TABLE IF EXISTS orders;

Read more

More in Destructive Operations