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 1 commit
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
Prev Previous commit
Next Next commit
added camelcase columns mapping
  • Loading branch information
odagora committed Sep 11, 2024
commit 7caec4b967fdb3eaa0aadbfc8ae180df3a87ef7e
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;
44 changes: 22 additions & 22 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ model WorkExperience {
description String? @db.VarChar(200)
startDate DateTime
endDate DateTime?
candidateId Int
candidateId Int @map("candidateId")
candidate Candidate @relation(fields: [candidateId], references: [id])
}

Expand All @@ -54,7 +54,7 @@ model Resume {
filePath String @db.VarChar(500)
fileType String @db.VarChar(50)
uploadDate DateTime
candidateId Int
candidateId Int @map("candidateId")
candidate Candidate @relation(fields: [candidateId], references: [id])
}

Expand All @@ -69,20 +69,20 @@ model Company {

model Employee {
id Int @id @default(autoincrement())
companyId Int
companyId Int @map("candidateId")
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
name String @db.VarChar(100)
email String @unique @db.VarChar(255)
role String? @db.VarChar(50)
isActive Boolean @default(true)
isActive Boolean @default(true) @map("isActive")
interviews Interview[]
@@index([companyId], name: "idx_employee_companyId")
}

model Position {
id Int @id @default(autoincrement())
companyId Int
interviewFlowId Int?
companyId Int @map("companyId")
interviewFlowId Int? @map("interviewFlowId")
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
interviewFlow InterviewFlow? @relation(fields: [interviewFlowId], references: [id], onDelete: SetNull)
title String @db.VarChar(255)
Expand Down Expand Up @@ -113,12 +113,12 @@ model InterviewFlow {
}

model InterviewStep {
id Int @id @default(autoincrement())
interviewFlowId Int
interviewTypeId Int?
interviewFlow InterviewFlow @relation(fields: [interviewFlowId], references: [id], onDelete: Cascade)
interviewType InterviewType? @relation(fields: [interviewTypeId], references: [id], onDelete: SetNull)
name String @db.VarChar(100)
id Int @id @default(autoincrement())
interviewFlowId Int @map("interviewFlowId")
interviewTypeId Int? @map("interviewTypeId")
interviewFlow InterviewFlow @relation(fields: [interviewFlowId], references: [id], onDelete: Cascade)
interviewType InterviewType? @relation(fields: [interviewTypeId], references: [id], onDelete: SetNull)
name String @db.VarChar(100)
orderIndex Int
interview Interview[]
@@index([interviewFlowId], name: "idx_interviewStep_interviewFlowId")
Expand All @@ -132,24 +132,24 @@ model InterviewType {
}

model Application {
id Int @id @default(autoincrement())
positionId Int
candidateId Int
position Position @relation(fields: [positionId], references: [id], onDelete: Cascade)
candidate Candidate @relation(fields: [candidateId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
positionId Int @map("positionId")
candidateId Int @map("candidateId")
position Position @relation(fields: [positionId], references: [id], onDelete: Cascade)
candidate Candidate @relation(fields: [candidateId], references: [id], onDelete: Cascade)
applicationDate DateTime
status String? @db.VarChar(50)
notes String? @db.Text
status String? @db.VarChar(50)
notes String? @db.Text
interviews Interview[]
@@index([positionId], name: "idx_application_positionId")
@@index([candidateId], name: "idx_application_candidateId")
}

model Interview {
id Int @id @default(autoincrement())
applicationId Int
interviewStepId Int
employeeId Int?
applicationId Int @map("applicationId")
interviewStepId Int @map("interviewStepId")
employeeId Int? @map("employeeId")
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)
interviewStep InterviewStep @relation(fields: [interviewStepId], references: [id], onDelete: Cascade)
employee Employee? @relation(fields: [employeeId], references: [id], onDelete: SetNull)
Expand Down