Next.js Discord

Discord Forum

Prisma, self relation onDelete, onUpdate behavior

Unanswered
Brewer's Blackbird posted this in #help-forum
Open in Discord
Brewer's BlackbirdOP
I have a prisma model:
model Comment {
    ...
    children Comment[] @relation("replies")
    parent   Comment?  @relation("replies", fields: [parentId], references: [id])
    parentId String?
}


I want to add onDelete: Cascade or onUpdate: Cascade, but it returns an error:
Error validating: A self-relation must have onDelete and onUpdate referential actions set to NoAction in one of the @relation attributes. (Implicit default onDelete: SetNull, and onUpdate: Cascade) Read more at https://pris.ly/d/cyclic-referential-actions

0 Replies