refactor: employee

This commit is contained in:
Methapon Metanipat 2024-09-13 17:39:12 +07:00
parent 77739da154
commit c51a403f2a
7 changed files with 637 additions and 277 deletions

View file

@ -0,0 +1,99 @@
/*
Warnings:
- You are about to drop the column `entryDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportExpiryDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportIssueDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportIssuingCountry` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportIssuingPlace` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportNumber` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `passportType` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `previousPassportReference` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `tm6Number` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaExpiryDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaIssueDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaIssuingPlace` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaNumber` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaStayUntilDate` on the `Employee` table. All the data in the column will be lost.
- You are about to drop the column `visaType` on the `Employee` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Employee" DROP COLUMN "entryDate",
DROP COLUMN "passportExpiryDate",
DROP COLUMN "passportIssueDate",
DROP COLUMN "passportIssuingCountry",
DROP COLUMN "passportIssuingPlace",
DROP COLUMN "passportNumber",
DROP COLUMN "passportType",
DROP COLUMN "previousPassportReference",
DROP COLUMN "tm6Number",
DROP COLUMN "visaExpiryDate",
DROP COLUMN "visaIssueDate",
DROP COLUMN "visaIssuingPlace",
DROP COLUMN "visaNumber",
DROP COLUMN "visaStayUntilDate",
DROP COLUMN "visaType",
ADD COLUMN "workerType" TEXT;
-- CreateTable
CREATE TABLE "EmployeePassport" (
"id" TEXT NOT NULL,
"number" TEXT NOT NULL,
"type" TEXT NOT NULL,
"issueDate" DATE NOT NULL,
"expireDate" DATE NOT NULL,
"issueCountry" TEXT NOT NULL,
"issuePlace" TEXT NOT NULL,
"previousPassportRef" TEXT,
"employeeId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "EmployeePassport_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "EmployeeVisa" (
"id" TEXT NOT NULL,
"number" TEXT NOT NULL,
"type" TEXT NOT NULL,
"entryCount" INTEGER NOT NULL,
"issueCountry" TEXT NOT NULL,
"issuePlace" TEXT NOT NULL,
"issueDate" DATE NOT NULL,
"expireDate" DATE NOT NULL,
"mrz" TEXT,
"remark" TEXT,
"employeeId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "EmployeeVisa_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "EmployeeInCountryNotice" (
"id" TEXT NOT NULL,
"noticeNumber" TEXT NOT NULL,
"noticeDate" TEXT NOT NULL,
"nextNoticeDate" DATE NOT NULL,
"tmNumber" TEXT NOT NULL,
"entryDate" DATE NOT NULL,
"travelBy" TEXT NOT NULL,
"travelFrom" TEXT NOT NULL,
"employeeId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "EmployeeInCountryNotice_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "EmployeePassport" ADD CONSTRAINT "EmployeePassport_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EmployeeVisa" ADD CONSTRAINT "EmployeeVisa_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EmployeeInCountryNotice" ADD CONSTRAINT "EmployeeInCountryNotice_employeeId_fkey" FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -552,23 +552,8 @@ model Employee {
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
subDistrictId String?
passportType String
passportNumber String
passportIssueDate DateTime @db.Date
passportExpiryDate DateTime @db.Date
passportIssuingCountry String
passportIssuingPlace String
previousPassportReference String?
visaType String?
visaNumber String?
visaIssueDate DateTime? @db.Date
visaExpiryDate DateTime? @db.Date
visaIssuingPlace String?
visaStayUntilDate DateTime? @db.Date
tm6Number String?
entryDate DateTime? @db.Date
workerStatus String?
workerType String?
workerStatus String?
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
customerBranchId String
@ -584,9 +569,12 @@ model Employee {
updatedBy User? @relation(name: "EmployeeUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
updatedByUserId String?
employeeCheckup EmployeeCheckup[]
employeeWork EmployeeWork[]
employeeOtherInfo EmployeeOtherInfo?
employeePassport EmployeePassport[]
employeeVisa EmployeeVisa[]
employeeInCountryNotice EmployeeInCountryNotice[]
employeeCheckup EmployeeCheckup[]
employeeWork EmployeeWork[]
employeeOtherInfo EmployeeOtherInfo?
editHistory EmployeeHistory[]
quotationWorker QuotationWorker[]
@ -606,6 +594,63 @@ model EmployeeHistory {
master Employee @relation(fields: [masterId], references: [id], onDelete: Cascade)
}
model EmployeePassport {
id String @id @default(cuid())
number String
type String
issueDate DateTime @db.Date
expireDate DateTime @db.Date
issueCountry String
issuePlace String
previousPassportRef String?
employee Employee @relation(fields: [employeeId], references: [id])
employeeId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model EmployeeVisa {
id String @id @default(cuid())
number String
type String
entryCount Int
issueCountry String
issuePlace String
issueDate DateTime @db.Date
expireDate DateTime @db.Date
mrz String?
remark String?
employee Employee @relation(fields: [employeeId], references: [id])
employeeId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model EmployeeInCountryNotice {
id String @id @default(cuid())
noticeNumber String
noticeDate String
nextNoticeDate DateTime @db.Date
tmNumber String
entryDate DateTime @db.Date
travelBy String
travelFrom String
employee Employee @relation(fields: [employeeId], references: [id])
employeeId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model EmployeeCheckup {
id String @id @default(cuid())