fix: delete tickets when their category is deleted (closes #384)

This commit is contained in:
Isaac 2023-02-18 20:48:42 +00:00
parent a43801edf1
commit bd1bc19548
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
6 changed files with 6 additions and 6 deletions

View File

@ -239,7 +239,7 @@ ALTER TABLE `questionAnswers` ADD CONSTRAINT `questionAnswers_userId_fkey` FOREI
ALTER TABLE `tags` ADD CONSTRAINT `tags_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `tickets` ADD CONSTRAINT `tickets_claimedById_fkey` FOREIGN KEY (`claimedById`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -188,7 +188,7 @@ model Ticket {
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
categoryId Int?
claimedBy User? @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
claimedById String? @db.VarChar(19)

View File

@ -255,7 +255,7 @@ ALTER TABLE "questionAnswers" ADD CONSTRAINT "questionAnswers_userId_fkey" FOREI
ALTER TABLE "tags" ADD CONSTRAINT "tags_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "tickets" ADD CONSTRAINT "tickets_claimedById_fkey" FOREIGN KEY ("claimedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -187,7 +187,7 @@ model Ticket {
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
categoryId Int?
claimedBy User? @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
claimedById String? @db.VarChar(19)

View File

@ -176,7 +176,7 @@ CREATE TABLE "tickets" (
"referencesMessageId" TEXT,
"referencesTicketId" TEXT,
"topic" TEXT,
CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "tickets_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "tickets_claimedById_fkey" FOREIGN KEY ("claimedById") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "tickets_closedById_fkey" FOREIGN KEY ("closedById") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "tickets_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,

View File

@ -187,7 +187,7 @@ model Ticket {
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
category Category? @relation(fields: [categoryId], references: [id], onDelete: Cascade)
categoryId Int?
claimedBy User? @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
claimedById String?