Error validating: You defined the enum `UserRole`. But the current connector does not support enums.

Solution:
Looks like you're using sqlite. You can: * have a UseRole table * if your project isn't that complex/big, you can just just store it as a string * isAdmin boolean (if that's all you'll need)?...
Jump to solution
10 Replies
Amit
Amit16mo ago
is it using sqlite connector ? as the error says, all connectors donot support enum. sqlite doesn't afaik
Solution
Mocha
Mocha16mo ago
Looks like you're using sqlite. You can: * have a UseRole table * if your project isn't that complex/big, you can just just store it as a string * isAdmin boolean (if that's all you'll need)?
gave_one
gave_one16mo ago
@100xdev @amit13 Error validating model "User": Ambiguous relation detected. The fields classes and courses in model User both refer to Courses. Please provide different relation names for them by adding `@relation(<name>).
model User {
id String @id @default(cuid())
name String?
email String? @unique
password String? @unique
emailVerified DateTime?
image String?
admin Boolean @default(false)
classes Courses[]
courses Courses @relation(fields: [coursesId], references: [id])
coursesId String @unique

accounts Account[]
sessions Session[]
}
model Courses{
id String @id @default(cuid())
name String
Description String?
fullMarks Int
startDate DateTime
endDate DateTime
teacher User?
user User @relation(fields: [UserId], references: [id])
UserId String @unique
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
password String? @unique
emailVerified DateTime?
image String?
admin Boolean @default(false)
classes Courses[]
courses Courses @relation(fields: [coursesId], references: [id])
coursesId String @unique

accounts Account[]
sessions Session[]
}
model Courses{
id String @id @default(cuid())
name String
Description String?
fullMarks Int
startDate DateTime
endDate DateTime
teacher User?
user User @relation(fields: [UserId], references: [id])
UserId String @unique
}
Mocha
Mocha16mo ago
What's the difference between courses and classes? How are you linking User.classes to Courses? Also note that coursesId String @unique means two students cannot share one coursesId
gave_one
gave_one16mo ago
each course must have a teacher or instructor The class in the user is for a student I have removed the @unique for both model @100xdev I think I will take a different approach instead of me using a relationship system I will just Store the user ID in the course instead
Mocha
Mocha16mo ago
Looks like you have a many-to-many relationship. One User can have many courses (regardless teacher or student, that could be a userRole or isTeacher column)
gave_one
gave_one16mo ago
so I have to add another model
gave_one
gave_one16mo ago
gave_one
gave_one16mo ago
what I did I have one relationship then I just store the ID of the user/teacher end the course
Mocha
Mocha16mo ago
That makes sense for JSON, but for sqlite, I suggest having a separate table for the relationship. And if a course can only be taught by one teacher, you can have Courses.teacherId that references the teacher user
Want results from more Discord servers?
Add your server