Skip to content

Postgres enum migration issue (migrations not being committed individually) #3466

Description

@michaelgmcd

Generating and running a migration for the following change:

const status = pgEnum('status', ['ONE', 'TWO', 'THREE']);

export const clients = pgTable('clients', {
  // ...
  status: status('status').notNull().default('ONE'),
});

to:

const status = pgEnum('status', ['FOUR']);

export const clients = pgTable('clients', {
  // ...
  status: status('status').notNull().default('FOUR'),
});

fails with:

PostgresError: unsafe use of new value "FOUR" of enum type status
...
hint: New enum values must be committed before they can be used.

I split the changes out into separate migrations (one to add the new value and another to use it), and I still receive the error. Is it possible to run each migration in an individual transaction to ensure the changes are committed before running the next one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions