All rules Rule BV039 · DW
PostgreSQL
note
DW · Deploy window
hosted, paid, --remote

Can I rename an enum value while old code is still running?

Enum value renamed inside the deploy window

Note: this works and blocks nothing, but a performance regression is likely.

What happens

RENAME VALUE changes the label in place: every app instance still deployed with the old label gets an invalid-enum error on insert or comparison until the rollout completes, the enum flavor of the rename deploy-window break.

Why it is dangerous on a populated table

Nothing blocks, but the cost scales with the table and shows up as a slower query plan or a longer maintenance window rather than an outage.

Fires on

ALTER TYPE order_status RENAME VALUE 'pending' TO 'awaiting';

The safe pattern

Treat enum labels like column names: add the new value in its own migration, deploy app code that reads both and writes the new one, convert existing rows in batches, and only retire the old label once nothing deployed uses it.

-- migration 1 (single statement, commits on its own):
ALTER TYPE order_status ADD VALUE IF NOT EXISTS 'awaiting';
-- deploy code reading both labels, batch-convert rows,
-- retire 'pending' only when no deployed code references it

Fixtures

The rule ships with these files and the test suite runs them on every change: the first set must fire, the second must stay silent.

Fires (1)

rename value
ALTER TYPE order_status RENAME VALUE 'pending' TO 'awaiting';

Stays silent (1)

add value
ALTER TYPE order_status ADD VALUE 'awaiting';

How to check locally

Catch this before it ships

This rule runs in the hosted service on Startup and above: add --remote with a team token, or use the GitHub Action. No install, nothing leaves your machine:

npx bolvrk check migration.sql --remote