Skip to content

no-pg-enum

CREATE TYPE ... AS ENUM — use TEXT with an application enum instead.

Why

PostgreSQL enums make ordinary value changes operationally awkward and couple application evolution to database type migrations.

Fix

Store the value as TEXT and validate its allowed values at the typed application boundary.

Examples

Before — flagged Executable dollar-quoted migration SQL remains checked
supabase/migrations/001_body.sql
DO $$ BEGIN CREATE TYPE status AS ENUM ('ready'); END $$;
After — preferred SQL keywords inside scalar dollar data are not executed
supabase/migrations/001_data.sql
SELECT
$data$CREATE TYPE status AS ENUM ('ready');$data$;
Before — flagged PostgreSQL enum type
supabase/migrations/001_status.sql
CREATE TYPE call_status AS ENUM('pending', 'active', 'completed');
After — preferred Text column whose closed values are application-owned
supabase/migrations/001_status.sql
CREATE TABLE
CALL (status TEXT NOT NULL);