Prisma 4.6.0 drops and recreates enum field when running db push even if the field has not changed
See original GitHub issueBug description
I just updated from Prisma 4.5.0 to 4.6.0 and now every time I run npx prisma db push
, even if I haven’t changed anything in schema.prisma
, Prisma wants to drop and recreate an enum field. I get this message:
The `roles` column on the `User` table would be dropped and recreated. This will lead to data loss
If I choose to ignore the warning all my data in the roles
column is reset.
After testing with multiple changes to my schema and simplifying it to the most basic form (included below) I downgraded to Prisma 4.5.0 and everything works as expected there. I’ve reconfirmed the problem exists by going back to Prisma 4.6.0.
How to reproduce
- Use the provided basic
schema.prisma.
Pay attention to theroles
field, which is an enum. - Create at least one row in the user table containing a value for the
roles
field. - Run
npx prisma db push
multiple times without changing anything inschema.prisma
. - You will see
The
rolescolumn on the
Usertable would be dropped and recreated. This will lead to data loss
, and if you accept the warning the data in theroles
column will be reset.
Expected behavior
The roles
enum column is not being changed in schema.prisma
so it shouldn’t be dropped and recreated when running npx prisma db push
.
Prisma information
model User {
id Int @id @default(autoincrement())
username String @unique @db.VarChar(32)
roles Role[] @default([COLLECTOR])
}
enum Role {
ADMIN
COLLECTOR
}
// Add your code using Prisma Client
Environment & setup
- OS: Ubuntu Linux
- Database: PostgreSQL 14.2
- Node.js version: 18.0.0
Prisma Version
4.6.0
Issue Analytics
- State:
- Created 10 months ago
- Reactions:19
- Comments:33 (18 by maintainers)
Top Results From Across the Web
Prisma 4.6.1 Release - GitClear
prisma /prisma ... 4.6.0 (released November 8, 2022) ... and recreates enum field when running db push even if the field has not...
Read more >Updating Enum Values in PostgreSQL - The Safe and Easy Way
"Drop and re-create the type." This solution alone is no good if the type is already in use as you would have to...
Read more >@prisma/engines: Versions | Openbase
Fix in Prisma Migrate. Prisma 4.6.0 drops and recreates enum field when running db push even if the field has not changed ......
Read more >how change the column of a table of enum type? - Laracasts
run as raw query is not good practice ... because it may not work on all database engine that laravel works with. solution...
Read more >Prisma Versions - Open Source Agenda
If your application encounters an error as the transaction is being ... Prisma 4.6.0 drops and recreates enum field when running db push...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jolg42
4.6.1-dev.1
fixed it for me@alexisbellido @rcbevans @bsproul @hoghweed @davidlumley Could you try to update
prisma
and@prisma/client
to the4.6.1-dev.1
internal patch version that includes the fixes and let us know if that solves your issue?We will wait for some confirmations before we publish the official patch to latest.