Hello, dear Prisma community! It took me a full d...
# orm-help
b
Hello, dear Prisma community! It took me a full day to research the alternatives, but I finally decided to go with Prisma for migrating my project from Ruby on Rails to Node.js. I am in the middle of replicating the queries, and got into a trouble while handling Enums in Prisma. I have just opened an Issue and would love to learn more about how it’s done here! Any help is deeply appreciated. Link to the issue: https://github.com/prisma/prisma/discussions/4149
t
You can definitely add enum values in schema with the enum keyword. Taking your example, below your User model
Copy code
model User {
  id        Int      @id @default(autoincrement())
  status    Int?     @default(0)
}
add your enums as
Copy code
enum UserStatus {
    STUDENT
    GENERALSPECIALIST
    DORMSPECIALIST
    DORMSUPERVISOR
  }
Then reference the default on your user model as
Copy code
model User {
  id        Int      @id @default(autoincrement())
  status    UserStatus?     @default(STUDENT)
}
Try this out
b
Thank you for your answer, but it didn’t fix it. I replied in the issue.
r
@Bex replied in the discussion.
b
Found an issue, which caused the error. Check in replies