Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in migration when updating enum #15027

Closed
PauloPraf opened this issue Aug 26, 2022 · 8 comments
Closed

Error in migration when updating enum #15027

PauloPraf opened this issue Aug 26, 2022 · 8 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: enum "type"/block `enum` topic: migrate topic: postgresql

Comments

@PauloPraf
Copy link

Hi Prisma Team! Prisma Migrate just crashed.

Command

migrate dev

Versions

Name Version
Platform windows
Node v16.15.0
Prisma CLI 4.2.1
Engine 2920a97877e12e055c1333079b8d19cee7f33826

Error

Error: Error in migration engine.
Reason: [migration-engine\connectors\sql-migration-connector\src\sql_renderer\postgres_renderer.rs:908:22] We should only be setting a changed default if there was one on the previous schema and in the next with the same enum.

Please create an issue with your `schema.prisma` at
https://github.com/prisma/prisma/issues/new

@danstarns
Copy link
Contributor

Hey @PauloPraf,

Please could you share with us your Prisma schema?

@danstarns danstarns added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. topic: migrate team/schema Issue for team Schema. labels Aug 30, 2022
@OscarMulder
Copy link

I had this exact same error with the following schema change.

Before:

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  accounts      Account[]
  sessions      Session[]
  roles         Role[]    @default([STUDENT])
}

enum Role {
  STUDENT
  STAFF
  MONITORINGMANAGER
  ADMIN
}

Changed only the enum:

enum Role {
  STUDENT
  STAFF
  STUDENTAFFAIRS
  ADMIN
}

I got the following warning beforehand:

⚠️  Warnings for the current datasource:

  • The values [MONITORINGMANAGER] on the enum `Role` will be removed. If these variants are still used in the database, this will fail.

✔ Are you sure you want create and apply this migration? … yes

However there are no records in my database with the value MONITORINGMANAGER.

@OscarMulder
Copy link

After removing the @default([STUDENT]) the migration was successfully applied.

@janpio
Copy link
Member

janpio commented Aug 30, 2022

Was this also about changing an enum for you @PauloPraf?

@PauloPraf
Copy link
Author

Was this also about changing an enum for you @PauloPraf?

Yes, it was the same situation as described above.

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: enum "type"/block `enum` and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Aug 30, 2022
@janpio janpio changed the title Error in migration Error in migration when updating enum Aug 30, 2022
@janpio janpio added the kind/bug A reported bug. label Aug 30, 2022
@jkomyno
Copy link
Contributor

jkomyno commented Sep 2, 2022

Another report: https://prisma-errors.netlify.app/report/14266

@Jolg42
Copy link
Member

Jolg42 commented Aug 10, 2023

Hi @PauloPraf 👋🏼
It looks like this was fixed in 4.7.0, could you try upgrading to that version or a more recent one?

PR: prisma/prisma-engines#3379

@Jolg42
Copy link
Member

Jolg42 commented Aug 22, 2023

@PauloPraf I'll close this as it should be fixed already, let us know if it's indeed the case or if we should reopen this.

@Jolg42 Jolg42 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: enum "type"/block `enum` topic: migrate topic: postgresql
Projects
None yet
Development

No branches or pull requests

6 participants