I'm working with this particular prisma schema:
model Directory {
id String @id @default(cuid())
name String?
parentDirectoryId String?
userId String
parentDirectory Directory? @relation("parentDirectoryId", fields: [parentDirectoryId], references: [id], onDelete: NoAction, onUpdate: NoAction)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
quizess Quiz[]
subDirectory Directory[] @relation("parentDirectoryId")
@@index([parentDirectoryId])
@@index([userId])
}
The concept behind it: A folder can exist either at the root level (parentDirectoryId = null) or have several additional directories.
Question is, how do I delete a directory that contains other directories?
When attempting to use prisma.delete, I encounter the following issue:
Invalid
prisma.directory.delete()
The requested operation would violate the necessary relation 'parentDirectoryId' between the Directory
and Directory
models.`
Tried setting onDelete: Cascade, onUpdate: Cascade without success