Skip to content

prefer-constrained-status

Review CHECK-constrained boolean states for a single status column.

Why

A CHECK that rules out combinations of multiple required booleans exposes a shared state contract. A constrained status column can represent the permitted states explicitly and avoid invalid flag combinations.

Fix

Review whether these dependent booleans represent one lifecycle. If so, replace them with one status column and a CHECK over its allowed values, preserving every valid state and application transition.

Examples

Before — flagged A CHECK makes two required flags dependent
supabase/migrations/001_job.sql
CREATE TABLE job (
requested BOOLEAN NOT NULL,
confirmed BOOLEAN NOT NULL,
CHECK (
NOT confirmed
OR requested
)
);
After — preferred Unrelated flags retain their independent values
supabase/migrations/001_job.sql
CREATE TABLE job (
enabled BOOLEAN NOT NULL,
archived BOOLEAN NOT NULL
);