Partitions
ALTER TABLE ... DETACH PARTITION
ALTER TABLE orders DETACH PARTITION orders_2025_01; What this does
Without CONCURRENTLY, detaching a partition takes ACCESS EXCLUSIVE on the parent table.
Safe rewrite
Use DETACH PARTITION CONCURRENTLY (PostgreSQL 14+) to avoid the ACCESS EXCLUSIVE lock
ALTER TABLE orders DETACH PARTITION orders_2025_01 CONCURRENTLY;
-- Note: DETACH CONCURRENTLY requires PG14+ and must run outside a transaction block