Handle deletions

This commit is contained in:
Isaac 2022-04-22 00:12:53 +01:00
parent 31a47614c7
commit 3e10448a1e

View File

@ -10,7 +10,7 @@ datasource db {
model ArchivedChannel {
channelId String @db.VarChar(19)
name String
ticket Ticket @relation(fields: [ticketId], references: [id])
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
@@id([ticketId, channelId])
@ -19,13 +19,13 @@ model ArchivedChannel {
}
model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId])
author ArchivedUser? @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: SetNull)
authorId String @db.VarChar(19)
data Json
deleted Boolean @default(false)
edited Boolean @default(false)
id String @id @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
@@map("archived_messages")
@ -36,7 +36,7 @@ model ArchivedRole {
colour String @default("7289DA") @db.Char(6)
name String
roleId String @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
@@id([ticketId, roleId])
@ -50,9 +50,9 @@ model ArchivedUser {
bot Boolean @default(false)
discriminator String @db.Char(4)
displayName String
role ArchivedRole @relation(fields: [ticketId, roleId], references: [ticketId, roleId])
role ArchivedRole? @relation(fields: [ticketId, roleId], references: [ticketId, roleId], onDelete: SetNull)
roleId String @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
userId String @db.VarChar(19)
username String
@ -118,7 +118,7 @@ model Ticket {
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category @relation(fields: [categoryId], references: [id])
category Category @relation(fields: [categoryId], references: [id], onDelete: SetNull)
categoryId Int
claimedBy User @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
claimedById String @db.VarChar(19)