SQLSTATE 55P04 ERROR Class 55: Object Not In Prerequisite State

unsafe_new_enum_value_usage unsafe use of new value of enum type — 55P04

PostgreSQL error “unsafe use of new value of enum type — 55P04” (SQLSTATE 55P04): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

A newly added enum value was used in the same transaction that added it, which is unsafe. PostgreSQL raises SQLSTATE 55P04 (unsafe_new_enum_value_usage).

  • A value added by ALTER TYPE … ADD VALUE was used before commit.
  • New enum values can’t be used in the same transaction (in some cases).
  • Common in migrations that add and then use a value.

What the server log shows

ERROR:  unsafe use of new value "shipped" of enum type order_status
HINT:  New enum values must be committed before they can be used.

Why PostgreSQL raises this — what the manual says

the ALTER TYPE reference (Notes):

“ADD VALUE (the form that adds a new value to an enum type) is executed inside a transaction block, the new value cannot be used until after the transaction has been committed.”

Adding an enum value writes catalog state that other parts of the system rely on being committed before the value can be safely compared/stored. Using it within the same uncommitted transaction risks inconsistency, so PostgreSQL reports 55P04.

Common causes

  • Adding an enum value and inserting/using it in one transaction.
  • A migration that combines ADD VALUE with data changes.

How to fix it

  1. Commit the ADD VALUE first, then use the value in a separate transaction.
  2. Split migrations so enum additions are committed before use.
  3. Run ALTER TYPE … ADD VALUE outside the data-loading transaction.

Related & next steps

Reference: PostgreSQL 18 — ALTER TYPE.

Was this helpful?