question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma Migrate - Can't add value to enum in Postgres Database

See original GitHub issue

Bug description

I have an enum value and I would like to expand the possible values. The migration file is created successfully, but when running the migration I get the following error:

ERROR: ALTER TYPE ... ADD cannot run inside a transaction block

How to reproduce

  1. Create a migration with an enum and run migrate
  2. Add a value to the enum, create a new migration, and try to run migrate
  3. See issue

Fix could be this: https://stackoverflow.com/questions/53149484/error-alter-type-add-cannot-run-inside-a-transaction-block

Expected behavior

An error is not thrown

Prisma information

enum ModelType { TEST_1 TEST_2 TEST_3 }

Environment & setup

Debian (mac) 11.3.1

Prisma Version

2.23.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bryanmcgranecommented, May 25, 2021

I was on PG 11. I ended up upgrading to 12 and it was fixed. I’m not sure the total marketshare for PG 11, so up to you if you think it’s worth fixing!

0reactions
tomhoulecommented, Aug 24, 2021

Could we fix this by always generating multiple ALTER TYPEs? It’s uglier, but it would work on all versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a new value to an existing ENUM Type In prisma
In Postgres it is a relative simple ALTER TYPE add value vvvv; The most difficult may be deciding the sort order you want....
Read more >
About the shadow database - Prisma
When you run prisma migrate dev to create a new migration, Prisma Migrate uses the shadow database to: Detect schema drift, which means...
Read more >
Working with scalar lists/arrays (Concepts) - Prisma
Unsetting the value of a scalar list. This method is available on MongoDB only in versions 3.11.1 and later. The following example demonstrates...
Read more >
What is introspection? (Reference) - Prisma
This is most commonly the case when you're not using Prisma Migrate but perform schema migrations using plain SQL or another migration tool....
Read more >
Prisma schema (Reference)
The Prisma schema is the main configuration file when using Prisma. It is typically called schema.prisma and contains your database connection and data ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found