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