Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODG - Prisma Data Model Update #7

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
-- CreateTable
CREATE TABLE "Candidate" (
"id" SERIAL NOT NULL,
"firstName" VARCHAR(100) NOT NULL,
"lastName" VARCHAR(100) NOT NULL,
"email" VARCHAR(255) NOT NULL,
"phone" VARCHAR(15),
"address" VARCHAR(100),

CONSTRAINT "Candidate_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Education" (
"id" SERIAL NOT NULL,
"institution" VARCHAR(100) NOT NULL,
"title" VARCHAR(250) NOT NULL,
"startDate" TIMESTAMP(3) NOT NULL,
"endDate" TIMESTAMP(3),
"candidateId" INTEGER NOT NULL,

CONSTRAINT "Education_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "WorkExperience" (
"id" SERIAL NOT NULL,
"company" VARCHAR(100) NOT NULL,
"position" VARCHAR(100) NOT NULL,
"description" VARCHAR(200),
"startDate" TIMESTAMP(3) NOT NULL,
"endDate" TIMESTAMP(3),
"candidateId" INTEGER NOT NULL,

CONSTRAINT "WorkExperience_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Resume" (
"id" SERIAL NOT NULL,
"filePath" VARCHAR(500) NOT NULL,
"fileType" VARCHAR(50) NOT NULL,
"uploadDate" TIMESTAMP(3) NOT NULL,
"candidateId" INTEGER NOT NULL,

CONSTRAINT "Resume_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Candidate_email_key" ON "Candidate"("email");

-- AddForeignKey
ALTER TABLE "Education" ADD CONSTRAINT "Education_candidateId_fkey" FOREIGN KEY ("candidateId") REFERENCES "Candidate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "WorkExperience" ADD CONSTRAINT "WorkExperience_candidateId_fkey" FOREIGN KEY ("candidateId") REFERENCES "Candidate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Resume" ADD CONSTRAINT "Resume_candidateId_fkey" FOREIGN KEY ("candidateId") REFERENCES "Candidate"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
-- CreateTable
CREATE TABLE "Company" (
"id" SERIAL NOT NULL,
"name" VARCHAR(255) NOT NULL,

CONSTRAINT "Company_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Employee" (
"id" SERIAL NOT NULL,
"companyId" INTEGER NOT NULL,
"name" VARCHAR(100) NOT NULL,
"email" VARCHAR(255) NOT NULL,
"role" VARCHAR(50),
"isActive" BOOLEAN NOT NULL DEFAULT true,

CONSTRAINT "Employee_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Position" (
"id" SERIAL NOT NULL,
"companyId" INTEGER NOT NULL,
"interviewFlowId" INTEGER,
"title" VARCHAR(255) NOT NULL,
"description" TEXT,
"status" VARCHAR(50) NOT NULL,
"isVisible" BOOLEAN NOT NULL DEFAULT true,
"location" VARCHAR(255),
"jobDescription" TEXT,
"requirements" TEXT,
"responsibilities" TEXT,
"salaryMin" DOUBLE PRECISION,
"salaryMax" DOUBLE PRECISION,
"employmentType" VARCHAR(50),
"benefits" TEXT,
"companyDescription" TEXT,
"applicationDeadline" TIMESTAMP(3),
"contactInfo" VARCHAR(255),

CONSTRAINT "Position_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "InterviewFlow" (
"id" SERIAL NOT NULL,
"description" TEXT,

CONSTRAINT "InterviewFlow_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "InterviewStep" (
"id" SERIAL NOT NULL,
"interviewFlowId" INTEGER NOT NULL,
"interviewTypeId" INTEGER,
"name" VARCHAR(100) NOT NULL,
"orderIndex" INTEGER NOT NULL,

CONSTRAINT "InterviewStep_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "InterviewType" (
"id" SERIAL NOT NULL,
"name" VARCHAR(100) NOT NULL,
"description" TEXT,

CONSTRAINT "InterviewType_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Application" (
"id" SERIAL NOT NULL,
"positionId" INTEGER NOT NULL,
"candidateId" INTEGER NOT NULL,
"applicationDate" TIMESTAMP(3) NOT NULL,
"status" VARCHAR(50),
"notes" TEXT,

CONSTRAINT "Application_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Interview" (
"id" SERIAL NOT NULL,
"applicationId" INTEGER NOT NULL,
"interviewStepId" INTEGER NOT NULL,
"employeeId" INTEGER,
"interviewDate" TIMESTAMP(3),
"result" VARCHAR(50),
"score" INTEGER,
"notes" TEXT,

CONSTRAINT "Interview_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Employee_email_key" ON "Employee"("email");

-- AddForeignKey
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Position" ADD CONSTRAINT "Position_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Position" ADD CONSTRAINT "Position_interviewFlowId_fkey" FOREIGN KEY ("interviewFlowId") REFERENCES "InterviewFlow"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "InterviewStep" ADD CONSTRAINT "InterviewStep_interviewFlowId_fkey" FOREIGN KEY ("interviewFlowId") REFERENCES "InterviewFlow"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "InterviewStep" ADD CONSTRAINT "InterviewStep_interviewTypeId_fkey" FOREIGN KEY ("interviewTypeId") REFERENCES "InterviewType"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Application" ADD CONSTRAINT "Application_positionId_fkey" FOREIGN KEY ("positionId") REFERENCES "Position"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Application" ADD CONSTRAINT "Application_candidateId_fkey" FOREIGN KEY ("candidateId") REFERENCES "Candidate"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Interview" ADD CONSTRAINT "Interview_applicationId_fkey" FOREIGN KEY ("applicationId") REFERENCES "Application"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Interview" ADD CONSTRAINT "Interview_interviewStepId_fkey" FOREIGN KEY ("interviewStepId") REFERENCES "InterviewStep"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Interview" ADD CONSTRAINT "Interview_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE SET NULL ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- CreateIndex
CREATE INDEX "idx_application_positionId" ON "Application"("positionId");

-- CreateIndex
CREATE INDEX "idx_application_candidateId" ON "Application"("candidateId");

-- CreateIndex
CREATE INDEX "idx_employee_companyId" ON "Employee"("companyId");

-- CreateIndex
CREATE INDEX "idx_interview_applicationId" ON "Interview"("applicationId");

-- CreateIndex
CREATE INDEX "idx_interview_employeeId" ON "Interview"("employeeId");

-- CreateIndex
CREATE INDEX "idx_interviewStep_interviewFlowId" ON "InterviewStep"("interviewFlowId");

-- CreateIndex
CREATE INDEX "idx_position_companyId" ON "Position"("companyId");

-- CreateIndex
CREATE INDEX "idx_position_interviewFlowId" ON "Position"("interviewFlowId");
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Warnings:

- You are about to drop the column `companyId` on the `Employee` table. All the data in the column will be lost.
- Added the required column `candidateId` to the `Employee` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "Employee" DROP CONSTRAINT "Employee_companyId_fkey";

-- DropIndex
DROP INDEX "idx_employee_companyId";

-- AlterTable
ALTER TABLE "Employee" DROP COLUMN "companyId",
ADD COLUMN "candidateId" INTEGER NOT NULL;

-- CreateIndex
CREATE INDEX "idx_employee_companyId" ON "Employee"("candidateId");

-- AddForeignKey
ALTER TABLE "Employee" ADD CONSTRAINT "Employee_candidateId_fkey" FOREIGN KEY ("candidateId") REFERENCES "Company"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Loading