Harris Rothaermel
09/09/2022, 11:20 PMmodel Conversation {
id String @id @default(uuid())
channelId String
active Boolean @default(true)
messages Message[]
participants User[]
summary String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([channelId, active], name: "active_conversation")
}
I was hoping to create a constraint that there is only ever 1 active (active = true) conversation in a channel, but I realized is that with the constraint as shown above, it actually prevents non-active conversations from being stored if there is already a non-active conversation in the same channelHarshit
09/12/2022, 10:01 AMchannelId
.
Prisma also doesn’t support SQL Check constraints yet: https://github.com/prisma/prisma/issues/3388 so it is also not possible right now to store constraint information in the schema.