Prisma schema delete many to many
Hi, I have some troubles deleting a many to many relationship / data. Currently it says:
This is the related schema:
prisma:error
Invalid `prisma.templateTag.deleteMany()` invocation:
Foreign key constraint failed on the field: `TagsOnTemplate_tagId_fkey (index)`
❌ tRPC failed on template.delete:
Invalid `prisma.templateTag.deleteMany()` invocation:
Foreign key constraint failed on the field: `TagsOnTemplate_tagId_fkey (index)`prisma:error
Invalid `prisma.templateTag.deleteMany()` invocation:
Foreign key constraint failed on the field: `TagsOnTemplate_tagId_fkey (index)`
❌ tRPC failed on template.delete:
Invalid `prisma.templateTag.deleteMany()` invocation:
Foreign key constraint failed on the field: `TagsOnTemplate_tagId_fkey (index)`This is the related schema:
model TemplateTag {
id String @id @default(cuid())
tag String @unique
templates TagsOnTemplate[]
}
model Template {
id String @id @default(cuid())
name String
description String?
visibility String @default("private")
filename String
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
tags TagsOnTemplate[]
}
model TagsOnTemplate {
id String @id @default(cuid())
template Template @relation(fields: [templateId], references: [id])
templateId String
tag TemplateTag @relation(fields: [tagId], references: [id])
tagId String
}model TemplateTag {
id String @id @default(cuid())
tag String @unique
templates TagsOnTemplate[]
}
model Template {
id String @id @default(cuid())
name String
description String?
visibility String @default("private")
filename String
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
tags TagsOnTemplate[]
}
model TagsOnTemplate {
id String @id @default(cuid())
template Template @relation(fields: [templateId], references: [id])
templateId String
tag TemplateTag @relation(fields: [tagId], references: [id])
tagId String
}