SQLSTATE 55006 ERROR Class 55: Object Not In Prerequisite State

object_in_use cannot ALTER TABLE “…” because it has pending trigger events — 55006

PostgreSQL error "cannot ALTER TABLE "…" because it has pending trigger events" (SQLSTATE 55006): what it means, common causes, and how to fix it.

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

Diagnostic Queries

Symptoms

An ALTER TABLE could not proceed because the table has pending (deferred) trigger events from the current transaction. PostgreSQL raises SQLSTATE 55006 (object_in_use).

  • Deferred constraint/trigger events are queued for the table.
  • ALTER TABLE conflicts with those pending events.
  • Common when altering inside a transaction that touched the table.

What the server log shows

ERROR:  cannot ALTER TABLE "orders" because it has pending trigger events

Why PostgreSQL raises this — what the manual says

As the ALTER TABLE reference explains:

ALTER TABLE cannot run while the current transaction still has unfired (deferred) trigger events queued against the table, because the pending row changes would be invalidated by the schema change; those events must be resolved first.

Deferred triggers/constraints queue events to run at commit. Altering the table’s structure while such events are pending would leave them inconsistent, so PostgreSQL blocks the ALTER with 55006.

Common causes

  • Deferred constraint checks queued earlier in the same transaction.
  • Altering a table you just modified within an open transaction.
  • AFTER triggers with deferred firing.

How to fix it

  1. Commit or roll back the current transaction first, then run ALTER TABLE.
  2. Run the ALTER in its own transaction before touching the table’s data.
  3. Use SET CONSTRAINTS … IMMEDIATE to flush deferred checks before altering.

Related & next steps

Reference: PostgreSQL 18 — ALTER TABLE.

Was this helpful?