From 7e4039dcce41a9705ca84f184adc14768568bbd8 Mon Sep 17 00:00:00 2001 From: Isaac Date: Thu, 9 Mar 2023 14:45:26 +0000 Subject: [PATCH] fix(schema): feedback cascading deletion --- .../migration.sql | 4 +-- db/mysql/schema.prisma | 4 +-- .../migration.sql | 4 +-- db/postgresql/schema.prisma | 4 +-- .../migration.sql | 4 +-- db/sqlite/schema.prisma | 4 +-- package.json | 6 ++-- pnpm-lock.yaml | 30 +++++++++---------- 8 files changed, 30 insertions(+), 30 deletions(-) rename db/mysql/migrations/{20230218204428_4_0_0 => 20230309144248_4_0_0}/migration.sql (98%) rename db/postgresql/migrations/{20230218204642_4_0_0 => 20230309132703_4_0_0}/migration.sql (98%) rename db/sqlite/migrations/{20230218204317_4_0_0 => 20230309142817_4_0_0}/migration.sql (98%) diff --git a/db/mysql/migrations/20230218204428_4_0_0/migration.sql b/db/mysql/migrations/20230309144248_4_0_0/migration.sql similarity index 98% rename from db/mysql/migrations/20230218204428_4_0_0/migration.sql rename to db/mysql/migrations/20230309144248_4_0_0/migration.sql index 29bd31e..498761e 100644 --- a/db/mysql/migrations/20230218204428_4_0_0/migration.sql +++ b/db/mysql/migrations/20230309144248_4_0_0/migration.sql @@ -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; -- 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 -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 ALTER TABLE `questions` ADD CONSTRAINT `questions_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/mysql/schema.prisma b/db/mysql/schema.prisma index 9dcfee6..305dffb 100644 --- a/db/mysql/schema.prisma +++ b/db/mysql/schema.prisma @@ -103,9 +103,9 @@ model Feedback { guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guildId String @db.VarChar(19) rating Int - ticket Ticket @relation(fields: [ticketId], references: [id]) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) 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) @@map("feedback") diff --git a/db/postgresql/migrations/20230218204642_4_0_0/migration.sql b/db/postgresql/migrations/20230309132703_4_0_0/migration.sql similarity index 98% rename from db/postgresql/migrations/20230218204642_4_0_0/migration.sql rename to db/postgresql/migrations/20230309132703_4_0_0/migration.sql index 5abd9a7..062c17a 100644 --- a/db/postgresql/migrations/20230218204642_4_0_0/migration.sql +++ b/db/postgresql/migrations/20230309132703_4_0_0/migration.sql @@ -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; -- 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 -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 ALTER TABLE "questions" ADD CONSTRAINT "questions_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/postgresql/schema.prisma b/db/postgresql/schema.prisma index b20b0ac..7e7841b 100644 --- a/db/postgresql/schema.prisma +++ b/db/postgresql/schema.prisma @@ -102,9 +102,9 @@ model Feedback { guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guildId String @db.VarChar(19) rating Int - ticket Ticket @relation(fields: [ticketId], references: [id]) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) 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) @@map("feedback") diff --git a/db/sqlite/migrations/20230218204317_4_0_0/migration.sql b/db/sqlite/migrations/20230309142817_4_0_0/migration.sql similarity index 98% rename from db/sqlite/migrations/20230218204317_4_0_0/migration.sql rename to db/sqlite/migrations/20230309142817_4_0_0/migration.sql index 308773b..29d423a 100644 --- a/db/sqlite/migrations/20230218204317_4_0_0/migration.sql +++ b/db/sqlite/migrations/20230309142817_4_0_0/migration.sql @@ -87,8 +87,8 @@ CREATE TABLE "feedback" ( "ticketId" TEXT NOT NULL PRIMARY KEY, "userId" TEXT, 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_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE SET NULL 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 CASCADE ON UPDATE CASCADE ); -- CreateTable diff --git a/db/sqlite/schema.prisma b/db/sqlite/schema.prisma index ebad7ce..7c080b0 100644 --- a/db/sqlite/schema.prisma +++ b/db/sqlite/schema.prisma @@ -102,9 +102,9 @@ model Feedback { guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guildId String rating Int - ticket Ticket @relation(fields: [ticketId], references: [id]) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) ticketId String @id - user User? @relation(fields: [userId], references: [id]) + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) userId String? @@map("feedback") diff --git a/package.json b/package.json index aeb15dd..bc61256 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-tickets", - "version": "4.0.0-beta.5", + "version": "4.0.0-beta.6", "private": "true", "description": "An open-source Discord bot for ticket management", "main": "src/", @@ -49,7 +49,7 @@ "@fastify/http-proxy": "^8.4.0", "@fastify/jwt": "^5.0.1", "@fastify/oauth2": "^5.1.0", - "@prisma/client": "^4.10.1", + "@prisma/client": "^4.11.0", "boxen": "^7.0.2", "cryptr": "^6.1.0", "discord.js": "^14.7.1", @@ -66,7 +66,7 @@ "node-dir": "^0.1.17", "node-emoji": "^1.11.0", "object-diffy": "^1.0.4", - "prisma": "^4.10.1", + "prisma": "^4.11.0", "semver": "^7.3.8", "terminal-link": "^2.1.1", "yaml": "^1.10.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb6f6bc..2847364 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,7 +12,7 @@ specifiers: '@fastify/http-proxy': ^8.4.0 '@fastify/jwt': ^5.0.1 '@fastify/oauth2': ^5.1.0 - '@prisma/client': ^4.10.1 + '@prisma/client': ^4.11.0 all-contributors-cli: ^6.24.0 boxen: ^7.0.2 bufferutil: ^4.0.7 @@ -38,7 +38,7 @@ specifiers: node-emoji: ^1.11.0 nodemon: ^2.0.20 object-diffy: ^1.0.4 - prisma: ^4.10.1 + prisma: ^4.11.0 semver: ^7.3.8 terminal-link: ^2.1.1 utf-8-validate: ^5.0.10 @@ -55,7 +55,7 @@ dependencies: '@fastify/http-proxy': 8.4.0_3cxu5zja4e2r5wmvge7mdcljwq '@fastify/jwt': 5.0.1 '@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 cryptr: 6.1.0 discord.js: 14.7.1_3cxu5zja4e2r5wmvge7mdcljwq @@ -72,7 +72,7 @@ dependencies: node-dir: 0.1.17 node-emoji: 1.11.0 object-diffy: 1.0.4 - prisma: 4.10.1 + prisma: 4.11.0 semver: 7.3.8 terminal-link: 2.1.1 yaml: 1.10.2 @@ -600,8 +600,8 @@ packages: fastq: 1.15.0 dev: true - /@prisma/client/4.10.1_prisma@4.10.1: - resolution: {integrity: sha512-VonXLJZybdt8e5XZH5vnIGCRNnIh6OMX1FS3H/yzMGLT3STj5TJ/OkMcednrvELgk8PK89Vo3aSh51MWNO0axA==} + /@prisma/client/4.11.0_prisma@4.11.0: + resolution: {integrity: sha512-0INHYkQIqgAjrt7NzhYpeDQi8x3Nvylc2uDngKyFDDj1tTRQ4uV1HnVmd1sQEraeVAN63SOK0dgCKQHlvjL0KA==} engines: {node: '>=14.17'} requiresBuild: true peerDependencies: @@ -610,16 +610,16 @@ packages: prisma: optional: true dependencies: - '@prisma/engines-version': 4.10.1-2.aead147aa326ccb985dcfed5b065b4fdabd44b19 - prisma: 4.10.1 + '@prisma/engines-version': 4.11.0-57.8fde8fef4033376662cad983758335009d522acb + prisma: 4.11.0 dev: false - /@prisma/engines-version/4.10.1-2.aead147aa326ccb985dcfed5b065b4fdabd44b19: - resolution: {integrity: sha512-tsjTho7laDhf9EJ9EnDxAPEf7yrigSMDhniXeU4YoWc7azHAs4GPxRi2P9LTFonmHkJLMOLjR77J1oIP8Ife1w==} + /@prisma/engines-version/4.11.0-57.8fde8fef4033376662cad983758335009d522acb: + resolution: {integrity: sha512-3Vd8Qq06d5xD8Ch5WauWcUUrsVPdMC6Ge8ILji8RFfyhUpqon6qSyGM0apvr1O8n8qH8cKkEFqRPsYjuz5r83g==} dev: false - /@prisma/engines/4.10.1: - resolution: {integrity: sha512-B3tcTxjx196nuAu1GOTKO9cGPUgTFHYRdkPkTS4m5ptb2cejyBlH9X7GOfSt3xlI7p4zAJDshJP4JJivCg9ouA==} + /@prisma/engines/4.11.0: + resolution: {integrity: sha512-0AEBi2HXGV02cf6ASsBPhfsVIbVSDC9nbQed4iiY5eHttW9ZtMxHThuKZE1pnESbr8HRdgmFSa/Kn4OSNYuibg==} requiresBuild: true dev: false @@ -3240,13 +3240,13 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prisma/4.10.1: - resolution: {integrity: sha512-0jDxgg+DruB1kHVNlcspXQB9au62IFfVg9drkhzXudszHNUAQn0lVuu+T8np0uC2z1nKD5S3qPeCyR8u5YFLnA==} + /prisma/4.11.0: + resolution: {integrity: sha512-4zZmBXssPUEiX+GeL0MUq/Yyie4ltiKmGu7jCJFnYMamNrrulTBc+D+QwAQSJ01tyzeGHlD13kOnqPwRipnlNw==} engines: {node: '>=14.17'} hasBin: true requiresBuild: true dependencies: - '@prisma/engines': 4.10.1 + '@prisma/engines': 4.11.0 dev: false /process-nextick-args/2.0.1: