PostgreSQL 17 runners are live
All rules

SDB104[critical]Destructive

Table truncated

TRUNCATE deletes every row of a table that already exists.

Why it's risky in PostgreSQL

TRUNCATE removes all rows at once and can't be filtered. It also takes an ACCESS EXCLUSIVE lock. In a migration it runs against production data.

If the data really is disposable, say so with a suppression and a reason so reviewers see the decision.

What triggers it, and the safer way

unsafe.sql
TRUNCATE TABLE sessions;
safer.sql
-- shadowdb:allow SDB104 sessions are disposable; users re-login
TRUNCATE TABLE sessions;

Suppress it when you're sure

Put this comment on the line before the statement. The reason is required and shows in the report.

suppression
-- shadowdb:allow SDB104 <why this is safe here>

Applies to PostgreSQL 14, 15, 16, 17.