Prisma deleting wrong table?? WHY

Ok, here's what I want to do: I want to delete a EventMaster that is linked to a certain EventException. Here's my query:
await ctx.prisma.eventMaster.deleteMany({
where: {
workspaceId: ctx.session.user.activeWorkspaceId,
EventExceptions: {
some: {
id: input.eventExceptionId,
},
},
},
});
await ctx.prisma.eventMaster.deleteMany({
where: {
workspaceId: ctx.session.user.activeWorkspaceId,
EventExceptions: {
some: {
id: input.eventExceptionId,
},
},
},
});
FOR SOME REASON, this is deleting my EventException and not my EventMaster. I don't know why... this is scaring me because the query looks solid to me. I do have setup cascade deletes on my EventException, because I do want prisma to delete my EventException after I delete the EventMaster. However, it is not deleting the master at all and only the EventException. WHy is this happening?
1 Reply
Gabriel
Gabriel12mo ago
model EventMaster {
id String @id @default(cuid())
rule String
DateStart DateTime
DateUntil DateTime?

eventInfo EventInfo @relation(fields: [eventInfoId], references: [id])
eventInfoId String

EventExceptions EventException[]
EventCancellations EventCancellation[]
EventDone EventDone[]

Workspace Workspace @relation(fields: [workspaceId], references: [id])
workspaceId String

@@index([workspaceId])
@@index([eventInfoId])
}

model EventException {
id String @id @default(cuid())
originalDate DateTime
newDate DateTime

EventMaster EventMaster @relation(fields: [eventMasterId], references: [id], onDelete: Cascade)
eventMasterId String

EventInfo EventInfo? @relation(fields: [eventInfoId], references: [id])
eventInfoId String?

@@index([eventMasterId])
@@index([eventInfoId])
}
model EventMaster {
id String @id @default(cuid())
rule String
DateStart DateTime
DateUntil DateTime?

eventInfo EventInfo @relation(fields: [eventInfoId], references: [id])
eventInfoId String

EventExceptions EventException[]
EventCancellations EventCancellation[]
EventDone EventDone[]

Workspace Workspace @relation(fields: [workspaceId], references: [id])
workspaceId String

@@index([workspaceId])
@@index([eventInfoId])
}

model EventException {
id String @id @default(cuid())
originalDate DateTime
newDate DateTime

EventMaster EventMaster @relation(fields: [eventMasterId], references: [id], onDelete: Cascade)
eventMasterId String

EventInfo EventInfo? @relation(fields: [eventInfoId], references: [id])
eventInfoId String?

@@index([eventMasterId])
@@index([eventInfoId])
}
Here's my DB model ^^
Want results from more Discord servers?
Add your server