PostgreSQL 17 runners are live
All rules

SDB303[high]Rewrites

Table switched between LOGGED and UNLOGGED

SET LOGGED / SET UNLOGGED rewrites the table.

Why it's risky in PostgreSQL

Changing persistence rewrites the table and its indexes under an ACCESS EXCLUSIVE lock.

What triggers it, and the safer way

unsafe.sql
ALTER TABLE sessions SET LOGGED;
safer.sql
-- Create the table with the intended persistence from the start.
CREATE UNLOGGED TABLE cache_entries (k text PRIMARY KEY, v text);

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 SDB303 <why this is safe here>

Applies to PostgreSQL 14, 15, 16, 17.