fix(schema): feedback cascading deletion

This commit is contained in:
Isaac 2023-03-09 14:45:26 +00:00
parent f89419f4d0
commit 7e4039dcce
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
8 changed files with 30 additions and 30 deletions

View File

@ -218,10 +218,10 @@ ALTER TABLE `categories` ADD CONSTRAINT `categories_guildId_fkey` FOREIGN KEY (`
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `feedback` ADD CONSTRAINT `feedback_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `guilds`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE `feedback` ADD CONSTRAINT `feedback_ticketId_fkey` FOREIGN KEY (`ticketId`) REFERENCES `tickets`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE `feedback` ADD CONSTRAINT `feedback_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE `feedback` ADD CONSTRAINT `feedback_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE `questions` ADD CONSTRAINT `questions_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `questions` ADD CONSTRAINT `questions_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -103,9 +103,9 @@ model Feedback {
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
rating Int rating Int
ticket Ticket @relation(fields: [ticketId], references: [id]) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @id @db.VarChar(19) ticketId String @id @db.VarChar(19)
user User? @relation(fields: [userId], references: [id]) user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String? @db.VarChar(19) userId String? @db.VarChar(19)
@@map("feedback") @@map("feedback")

View File

@ -234,10 +234,10 @@ ALTER TABLE "categories" ADD CONSTRAINT "categories_guildId_fkey" FOREIGN KEY ("
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE "feedback" ADD CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE "feedback" ADD CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "feedback" ADD CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE "feedback" ADD CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "questions" ADD CONSTRAINT "questions_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE "questions" ADD CONSTRAINT "questions_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -102,9 +102,9 @@ model Feedback {
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
rating Int rating Int
ticket Ticket @relation(fields: [ticketId], references: [id]) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @id @db.VarChar(19) ticketId String @id @db.VarChar(19)
user User? @relation(fields: [userId], references: [id]) user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String? @db.VarChar(19) userId String? @db.VarChar(19)
@@map("feedback") @@map("feedback")

View File

@ -87,8 +87,8 @@ CREATE TABLE "feedback" (
"ticketId" TEXT NOT NULL PRIMARY KEY, "ticketId" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT, "userId" TEXT,
CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "feedback_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "feedback_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE CONSTRAINT "feedback_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
); );
-- CreateTable -- CreateTable

View File

@ -102,9 +102,9 @@ model Feedback {
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String guildId String
rating Int rating Int
ticket Ticket @relation(fields: [ticketId], references: [id]) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @id ticketId String @id
user User? @relation(fields: [userId], references: [id]) user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String? userId String?
@@map("feedback") @@map("feedback")

View File

@ -1,6 +1,6 @@
{ {
"name": "discord-tickets", "name": "discord-tickets",
"version": "4.0.0-beta.5", "version": "4.0.0-beta.6",
"private": "true", "private": "true",
"description": "An open-source Discord bot for ticket management", "description": "An open-source Discord bot for ticket management",
"main": "src/", "main": "src/",
@ -49,7 +49,7 @@
"@fastify/http-proxy": "^8.4.0", "@fastify/http-proxy": "^8.4.0",
"@fastify/jwt": "^5.0.1", "@fastify/jwt": "^5.0.1",
"@fastify/oauth2": "^5.1.0", "@fastify/oauth2": "^5.1.0",
"@prisma/client": "^4.10.1", "@prisma/client": "^4.11.0",
"boxen": "^7.0.2", "boxen": "^7.0.2",
"cryptr": "^6.1.0", "cryptr": "^6.1.0",
"discord.js": "^14.7.1", "discord.js": "^14.7.1",
@ -66,7 +66,7 @@
"node-dir": "^0.1.17", "node-dir": "^0.1.17",
"node-emoji": "^1.11.0", "node-emoji": "^1.11.0",
"object-diffy": "^1.0.4", "object-diffy": "^1.0.4",
"prisma": "^4.10.1", "prisma": "^4.11.0",
"semver": "^7.3.8", "semver": "^7.3.8",
"terminal-link": "^2.1.1", "terminal-link": "^2.1.1",
"yaml": "^1.10.2" "yaml": "^1.10.2"

View File

@ -12,7 +12,7 @@ specifiers:
'@fastify/http-proxy': ^8.4.0 '@fastify/http-proxy': ^8.4.0
'@fastify/jwt': ^5.0.1 '@fastify/jwt': ^5.0.1
'@fastify/oauth2': ^5.1.0 '@fastify/oauth2': ^5.1.0
'@prisma/client': ^4.10.1 '@prisma/client': ^4.11.0
all-contributors-cli: ^6.24.0 all-contributors-cli: ^6.24.0
boxen: ^7.0.2 boxen: ^7.0.2
bufferutil: ^4.0.7 bufferutil: ^4.0.7
@ -38,7 +38,7 @@ specifiers:
node-emoji: ^1.11.0 node-emoji: ^1.11.0
nodemon: ^2.0.20 nodemon: ^2.0.20
object-diffy: ^1.0.4 object-diffy: ^1.0.4
prisma: ^4.10.1 prisma: ^4.11.0
semver: ^7.3.8 semver: ^7.3.8
terminal-link: ^2.1.1 terminal-link: ^2.1.1
utf-8-validate: ^5.0.10 utf-8-validate: ^5.0.10
@ -55,7 +55,7 @@ dependencies:
'@fastify/http-proxy': 8.4.0_3cxu5zja4e2r5wmvge7mdcljwq '@fastify/http-proxy': 8.4.0_3cxu5zja4e2r5wmvge7mdcljwq
'@fastify/jwt': 5.0.1 '@fastify/jwt': 5.0.1
'@fastify/oauth2': 5.1.0 '@fastify/oauth2': 5.1.0
'@prisma/client': 4.10.1_prisma@4.10.1 '@prisma/client': 4.11.0_prisma@4.11.0
boxen: 7.0.2 boxen: 7.0.2
cryptr: 6.1.0 cryptr: 6.1.0
discord.js: 14.7.1_3cxu5zja4e2r5wmvge7mdcljwq discord.js: 14.7.1_3cxu5zja4e2r5wmvge7mdcljwq
@ -72,7 +72,7 @@ dependencies:
node-dir: 0.1.17 node-dir: 0.1.17
node-emoji: 1.11.0 node-emoji: 1.11.0
object-diffy: 1.0.4 object-diffy: 1.0.4
prisma: 4.10.1 prisma: 4.11.0
semver: 7.3.8 semver: 7.3.8
terminal-link: 2.1.1 terminal-link: 2.1.1
yaml: 1.10.2 yaml: 1.10.2
@ -600,8 +600,8 @@ packages:
fastq: 1.15.0 fastq: 1.15.0
dev: true dev: true
/@prisma/client/4.10.1_prisma@4.10.1: /@prisma/client/4.11.0_prisma@4.11.0:
resolution: {integrity: sha512-VonXLJZybdt8e5XZH5vnIGCRNnIh6OMX1FS3H/yzMGLT3STj5TJ/OkMcednrvELgk8PK89Vo3aSh51MWNO0axA==} resolution: {integrity: sha512-0INHYkQIqgAjrt7NzhYpeDQi8x3Nvylc2uDngKyFDDj1tTRQ4uV1HnVmd1sQEraeVAN63SOK0dgCKQHlvjL0KA==}
engines: {node: '>=14.17'} engines: {node: '>=14.17'}
requiresBuild: true requiresBuild: true
peerDependencies: peerDependencies:
@ -610,16 +610,16 @@ packages:
prisma: prisma:
optional: true optional: true
dependencies: dependencies:
'@prisma/engines-version': 4.10.1-2.aead147aa326ccb985dcfed5b065b4fdabd44b19 '@prisma/engines-version': 4.11.0-57.8fde8fef4033376662cad983758335009d522acb
prisma: 4.10.1 prisma: 4.11.0
dev: false dev: false
/@prisma/engines-version/4.10.1-2.aead147aa326ccb985dcfed5b065b4fdabd44b19: /@prisma/engines-version/4.11.0-57.8fde8fef4033376662cad983758335009d522acb:
resolution: {integrity: sha512-tsjTho7laDhf9EJ9EnDxAPEf7yrigSMDhniXeU4YoWc7azHAs4GPxRi2P9LTFonmHkJLMOLjR77J1oIP8Ife1w==} resolution: {integrity: sha512-3Vd8Qq06d5xD8Ch5WauWcUUrsVPdMC6Ge8ILji8RFfyhUpqon6qSyGM0apvr1O8n8qH8cKkEFqRPsYjuz5r83g==}
dev: false dev: false
/@prisma/engines/4.10.1: /@prisma/engines/4.11.0:
resolution: {integrity: sha512-B3tcTxjx196nuAu1GOTKO9cGPUgTFHYRdkPkTS4m5ptb2cejyBlH9X7GOfSt3xlI7p4zAJDshJP4JJivCg9ouA==} resolution: {integrity: sha512-0AEBi2HXGV02cf6ASsBPhfsVIbVSDC9nbQed4iiY5eHttW9ZtMxHThuKZE1pnESbr8HRdgmFSa/Kn4OSNYuibg==}
requiresBuild: true requiresBuild: true
dev: false dev: false
@ -3240,13 +3240,13 @@ packages:
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
dev: true dev: true
/prisma/4.10.1: /prisma/4.11.0:
resolution: {integrity: sha512-0jDxgg+DruB1kHVNlcspXQB9au62IFfVg9drkhzXudszHNUAQn0lVuu+T8np0uC2z1nKD5S3qPeCyR8u5YFLnA==} resolution: {integrity: sha512-4zZmBXssPUEiX+GeL0MUq/Yyie4ltiKmGu7jCJFnYMamNrrulTBc+D+QwAQSJ01tyzeGHlD13kOnqPwRipnlNw==}
engines: {node: '>=14.17'} engines: {node: '>=14.17'}
hasBin: true hasBin: true
requiresBuild: true requiresBuild: true
dependencies: dependencies:
'@prisma/engines': 4.10.1 '@prisma/engines': 4.11.0
dev: false dev: false
/process-nextick-args/2.0.1: /process-nextick-args/2.0.1: