From caec7b57bc5cd478d1c70299be26126585f09380 Mon Sep 17 00:00:00 2001 From: hpkoh Date: Sun, 9 Oct 2022 00:55:55 +0800 Subject: [PATCH] [questions][feat] update vote enum --- .../migration.sql | 30 +++++++++++++ apps/portal/prisma/schema.prisma | 43 +++++++++---------- 2 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 apps/portal/prisma/migrations/20221008165306_update_vote_enum/migration.sql diff --git a/apps/portal/prisma/migrations/20221008165306_update_vote_enum/migration.sql b/apps/portal/prisma/migrations/20221008165306_update_vote_enum/migration.sql new file mode 100644 index 00000000..bd09564a --- /dev/null +++ b/apps/portal/prisma/migrations/20221008165306_update_vote_enum/migration.sql @@ -0,0 +1,30 @@ +/* + Warnings: + + - Changed the type of `vote` on the `QuestionsAnswerCommentVote` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Changed the type of `vote` on the `QuestionsAnswerVote` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Changed the type of `vote` on the `QuestionsQuestionCommentVote` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Changed the type of `vote` on the `QuestionsQuestionVote` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + +*/ +-- CreateEnum +CREATE TYPE "Vote" AS ENUM ('UPVOTE', 'DOWNVOTE'); + +-- AlterTable +ALTER TABLE "QuestionsAnswerCommentVote" DROP COLUMN "vote", +ADD COLUMN "vote" "Vote" NOT NULL; + +-- AlterTable +ALTER TABLE "QuestionsAnswerVote" DROP COLUMN "vote", +ADD COLUMN "vote" "Vote" NOT NULL; + +-- AlterTable +ALTER TABLE "QuestionsQuestionCommentVote" DROP COLUMN "vote", +ADD COLUMN "vote" "Vote" NOT NULL; + +-- AlterTable +ALTER TABLE "QuestionsQuestionVote" DROP COLUMN "vote", +ADD COLUMN "vote" "Vote" NOT NULL; + +-- DropEnum +DROP TYPE "QuestionsVote"; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 6b712610..13287fea 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -60,6 +60,11 @@ model User { questionsAnswerCommentVotes QuestionsAnswerCommentVote[] } +enum Vote { + UPVOTE + DOWNVOTE +} + model VerificationToken { identifier String token String @unique @@ -172,12 +177,6 @@ model ResumesCommentVote { // use camelCase for field names, and try to name them consistently // across all models in this file. -enum QuestionsVote { - NO_VOTE - UPVOTE - DOWNVOTE -} - enum QuestionsQuestionType { CODING SYSTEM_DESIGN @@ -215,12 +214,12 @@ model QuestionsQuestionEncounter { } model QuestionsQuestionVote { - id String @id @default(cuid()) + id String @id @default(cuid()) questionId String userId String? - vote QuestionsVote - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + vote Vote + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt user User? @relation(fields: [userId], references: [id], onDelete: SetNull) question QuestionsQuestion @relation(fields: [questionId], references: [id], onDelete: Cascade) @@ -242,12 +241,12 @@ model QuestionsQuestionComment { } model QuestionsQuestionCommentVote { - id String @id @default(cuid()) + id String @id @default(cuid()) questionCommentId String userId String? - vote QuestionsVote - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + vote Vote + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt user User? @relation(fields: [userId], references: [id], onDelete: SetNull) comment QuestionsQuestionComment @relation(fields: [questionCommentId], references: [id], onDelete: Cascade) @@ -270,12 +269,12 @@ model QuestionsAnswer { } model QuestionsAnswerVote { - id String @id @default(cuid()) + id String @id @default(cuid()) answerId String userId String? - vote QuestionsVote - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + vote Vote + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt user User? @relation(fields: [userId], references: [id], onDelete: SetNull) answer QuestionsAnswer @relation(fields: [answerId], references: [id], onDelete: Cascade) @@ -297,12 +296,12 @@ model QuestionsAnswerComment { } model QuestionsAnswerCommentVote { - id String @id @default(cuid()) + id String @id @default(cuid()) answerCommentId String userId String? - vote QuestionsVote - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + vote Vote + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt user User? @relation(fields: [userId], references: [id], onDelete: SetNull) comment QuestionsAnswerComment @relation(fields: [answerCommentId], references: [id], onDelete: Cascade)