Move review to separate model

This commit is contained in:
2025-08-13 23:53:36 +02:00
parent befc678bdb
commit 900414727f
17 changed files with 403 additions and 155 deletions
@@ -0,0 +1,62 @@
-- CreateTable
CREATE TABLE "public"."Review"
(
"id" SERIAL NOT NULL,
"score" SMALLINT,
"review" TEXT,
"internalNote" TEXT,
"rankingValue" INTEGER,
"showcase" BOOLEAN NOT NULL DEFAULT false,
"answerId" INTEGER NOT NULL,
"reviewerId" INTEGER NOT NULL,
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(3) NOT NULL,
CONSTRAINT "Review_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Review_answerId_key" ON "public"."Review" ("answerId");
-- AddForeignKey
ALTER TABLE "public"."Review"
ADD CONSTRAINT "Review_answerId_fkey" FOREIGN KEY ("answerId") REFERENCES "public"."QuestAnswer" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "public"."Review"
ADD CONSTRAINT "Review_reviewerId_fkey" FOREIGN KEY ("reviewerId") REFERENCES "public"."User" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
insert into public."Review" ("internalNote",
"rankingValue",
review,
score,
showcase,
"reviewerId",
"answerId",
"updatedAt",
"createdAt")
select "internalNote",
"rankingValue",
review,
score,
showcase,
"reviewerId",
id,
"updatedAt",
"updatedAt"
from "QuestAnswer"
where "reviewerId" is not null;
-- DropForeignKey
ALTER TABLE "public"."QuestAnswer"
DROP CONSTRAINT "QuestAnswer_reviewerId_fkey";
-- AlterTable
ALTER TABLE "public"."QuestAnswer"
DROP COLUMN "internalNote",
DROP COLUMN "rankingValue",
DROP COLUMN "review",
DROP COLUMN "reviewerId",
DROP COLUMN "score",
DROP COLUMN "showcase",
ADD COLUMN "final" BOOLEAN NOT NULL DEFAULT false;