enum-value-used-in-transaction
warningNew enum value used in the same transaction
Why it's unsafe
This ALTER TYPE ... ADD VALUE adds an enum value that is used later in the same transaction. PostgreSQL forbids using a newly added enum value in the transaction that added it; the later statement fails at runtime with "unsafe use of new value".
Safe rewrite
Add the enum value in its own migration (or before BEGIN / outside the wrapping transaction) so it is committed before any statement uses it. Many migration tools wrap each migration in an implicit transaction — disable that for this migration if you must add and use the value together.
Example
Try it in the playground →Unsafe
BEGIN;
ALTER TYPE mood ADD VALUE 'happy';
UPDATE surveys SET mood = 'happy';
COMMIT;