CREATE TYPE IF NOT EXISTS in Postgres
09:10 08 May 2026

Postgres 17 rejects this syntax.

CREATE TYPE IF NOT EXISTS TASK_STATUS 
  AS ENUM ('TO_DO', 'IN_PROGRESS', 'DONE');

IF NOT EXISTS is important since it's part of a script that's executed on each application startup.

What are workarounds other than declaring an ugly PL/PGSQL block (the answer is posted 7 years ago, might be outdated)?

postgresql