From e2c8cec72304247aa8840f7a6f85999248fb5c64 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Fri, 7 Oct 2022 14:27:30 +0800 Subject: [PATCH] [resumes][chore] update migration file --- .../20221007060537_add_resumes/migration.sql | 94 ------------------- .../migration.sql | 74 +++++++++++++++ 2 files changed, 74 insertions(+), 94 deletions(-) delete mode 100644 apps/portal/prisma/migrations/20221007060537_add_resumes/migration.sql create mode 100644 apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql diff --git a/apps/portal/prisma/migrations/20221007060537_add_resumes/migration.sql b/apps/portal/prisma/migrations/20221007060537_add_resumes/migration.sql deleted file mode 100644 index b21aaf01..00000000 --- a/apps/portal/prisma/migrations/20221007060537_add_resumes/migration.sql +++ /dev/null @@ -1,94 +0,0 @@ --- CreateEnum -CREATE TYPE "ResumesSection" AS ENUM ('GENERAL', 'EDUCATION', 'EXPERIENCE', 'PROJECTS', 'SKILLS'); - --- CreateTable -CREATE TABLE "ResumesProfile" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - - CONSTRAINT "ResumesProfile_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ResumesResume" ( - "id" TEXT NOT NULL, - "resumesProfileId" TEXT NOT NULL, - "title" TEXT NOT NULL, - "role" TEXT NOT NULL, - "experience" TEXT NOT NULL, - "location" TEXT NOT NULL, - "url" TEXT NOT NULL, - "additionalInfo" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "ResumesResume_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ResumesStar" ( - "id" TEXT NOT NULL, - "resumesProfileId" TEXT NOT NULL, - "resumeId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ResumesStar_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ResumesComment" ( - "id" TEXT NOT NULL, - "resumesProfileId" TEXT NOT NULL, - "resumeId" TEXT NOT NULL, - "description" TEXT NOT NULL, - "section" "ResumesSection" NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "ResumesComment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ResumesCommentVote" ( - "id" TEXT NOT NULL, - "resumesProfileId" TEXT NOT NULL, - "commentId" TEXT NOT NULL, - "value" INTEGER NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "ResumesCommentVote_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "ResumesProfile_userId_key" ON "ResumesProfile"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "ResumesStar_resumeId_resumesProfileId_key" ON "ResumesStar"("resumeId", "resumesProfileId"); - --- CreateIndex -CREATE UNIQUE INDEX "ResumesCommentVote_commentId_resumesProfileId_key" ON "ResumesCommentVote"("commentId", "resumesProfileId"); - --- AddForeignKey -ALTER TABLE "ResumesProfile" ADD CONSTRAINT "ResumesProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesResume" ADD CONSTRAINT "ResumesResume_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesStar" ADD CONSTRAINT "ResumesStar_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesStar" ADD CONSTRAINT "ResumesStar_resumeId_fkey" FOREIGN KEY ("resumeId") REFERENCES "ResumesResume"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_resumeId_fkey" FOREIGN KEY ("resumeId") REFERENCES "ResumesResume"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesCommentVote" ADD CONSTRAINT "ResumesCommentVote_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ResumesCommentVote" ADD CONSTRAINT "ResumesCommentVote_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "ResumesComment"("id") ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql b/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql new file mode 100644 index 00000000..64ef6108 --- /dev/null +++ b/apps/portal/prisma/migrations/20221007062555_add_resume_profile_model/migration.sql @@ -0,0 +1,74 @@ +/* + Warnings: + + - You are about to drop the column `userId` on the `ResumesComment` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesCommentVote` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesResume` table. All the data in the column will be lost. + - You are about to drop the column `userId` on the `ResumesStar` table. All the data in the column will be lost. + - A unique constraint covering the columns `[commentId,resumesProfileId]` on the table `ResumesCommentVote` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[resumeId,resumesProfileId]` on the table `ResumesStar` will be added. If there are existing duplicate values, this will fail. + - Added the required column `resumesProfileId` to the `ResumesComment` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesCommentVote` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesResume` table without a default value. This is not possible if the table is not empty. + - Added the required column `resumesProfileId` to the `ResumesStar` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropForeignKey +ALTER TABLE "ResumesComment" DROP CONSTRAINT "ResumesComment_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesCommentVote" DROP CONSTRAINT "ResumesCommentVote_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesResume" DROP CONSTRAINT "ResumesResume_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "ResumesStar" DROP CONSTRAINT "ResumesStar_userId_fkey"; + +-- AlterTable +ALTER TABLE "ResumesComment" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesCommentVote" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesResume" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- AlterTable +ALTER TABLE "ResumesStar" DROP COLUMN "userId", +ADD COLUMN "resumesProfileId" TEXT NOT NULL; + +-- CreateTable +CREATE TABLE "ResumesProfile" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + + CONSTRAINT "ResumesProfile_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesProfile_userId_key" ON "ResumesProfile"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesCommentVote_commentId_resumesProfileId_key" ON "ResumesCommentVote"("commentId", "resumesProfileId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResumesStar_resumeId_resumesProfileId_key" ON "ResumesStar"("resumeId", "resumesProfileId"); + +-- AddForeignKey +ALTER TABLE "ResumesProfile" ADD CONSTRAINT "ResumesProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesResume" ADD CONSTRAINT "ResumesResume_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesStar" ADD CONSTRAINT "ResumesStar_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesComment" ADD CONSTRAINT "ResumesComment_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ResumesCommentVote" ADD CONSTRAINT "ResumesCommentVote_resumesProfileId_fkey" FOREIGN KEY ("resumesProfileId") REFERENCES "ResumesProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE;