From aba68af123addea0f2602c360dc1e3727282df82 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:50:17 +0700 Subject: [PATCH] fix: change structure --- .../migration.sql | 45 +++++++++++++++++++ prisma/schema.prisma | 20 +++++++-- src/controllers/employee-controller.ts | 45 ++++++++++++++----- 3 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 prisma/migrations/20240610094945_change_employee_fields/migration.sql diff --git a/prisma/migrations/20240610094945_change_employee_fields/migration.sql b/prisma/migrations/20240610094945_change_employee_fields/migration.sql new file mode 100644 index 0000000..e20d1e0 --- /dev/null +++ b/prisma/migrations/20240610094945_change_employee_fields/migration.sql @@ -0,0 +1,45 @@ +/* + Warnings: + + - You are about to drop the column `arrivalBarricade` on the `Employee` table. All the data in the column will be lost. + - You are about to drop the column `arrivalCardNo` on the `Employee` table. All the data in the column will be lost. + - You are about to drop the column `email` on the `Employee` table. All the data in the column will be lost. + - You are about to drop the column `telephoneNo` on the `Employee` table. All the data in the column will be lost. + - Added the required column `entryDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportExpiryDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportIssueDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportIssuingCountry` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportIssuingPlace` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportNumber` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `passportType` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `tm6Number` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaExpiryDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaIssueDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaIssuingPlace` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaNumber` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaStayUntilDate` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `visaType` to the `Employee` table without a default value. This is not possible if the table is not empty. + - Added the required column `workerStatus` to the `Employee` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Employee" DROP COLUMN "arrivalBarricade", +DROP COLUMN "arrivalCardNo", +DROP COLUMN "email", +DROP COLUMN "telephoneNo", +ADD COLUMN "entryDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "passportExpiryDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "passportIssueDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "passportIssuingCountry" TEXT NOT NULL, +ADD COLUMN "passportIssuingPlace" TEXT NOT NULL, +ADD COLUMN "passportNumber" TEXT NOT NULL, +ADD COLUMN "passportType" TEXT NOT NULL, +ADD COLUMN "previousPassportReference" TEXT, +ADD COLUMN "tm6Number" TEXT NOT NULL, +ADD COLUMN "visaExpiryDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "visaIssueDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "visaIssuingPlace" TEXT NOT NULL, +ADD COLUMN "visaNumber" TEXT NOT NULL, +ADD COLUMN "visaStayUntilDate" TIMESTAMP(3) NOT NULL, +ADD COLUMN "visaType" TEXT NOT NULL, +ADD COLUMN "workerStatus" TEXT NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a65e776..a93e1dc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -428,11 +428,23 @@ model Employee { zipCode String - email String - telephoneNo String + passportType String + passportNumber String + passportIssueDate DateTime + passportExpiryDate DateTime + passportIssuingCountry String + passportIssuingPlace String + previousPassportReference String? - arrivalBarricade String - arrivalCardNo String + visaType String + visaNumber String + visaIssueDate DateTime + visaExpiryDate DateTime + visaIssuingPlace String + visaStayUntilDate DateTime + tm6Number String + entryDate DateTime + workerStatus String customerBranch CustomerBranch? @relation(fields: [customerBranchId], references: [id], onDelete: SetNull) customerBranchId String? diff --git a/src/controllers/employee-controller.ts b/src/controllers/employee-controller.ts index afef206..e13c628 100644 --- a/src/controllers/employee-controller.ts +++ b/src/controllers/employee-controller.ts @@ -34,7 +34,6 @@ type EmployeeCreate = { status?: Status; - code: string; nrcNo: string; dateOfBirth: Date; @@ -49,11 +48,24 @@ type EmployeeCreate = { addressEN: string; address: string; zipCode: string; - email: string; - telephoneNo: string; - arrivalBarricade: string; - arrivalCardNo: string; + passportType: string; + passportNumber: string; + passportIssueDate: Date; + passportExpiryDate: Date; + passportIssuingCountry: string; + passportIssuingPlace: string; + previousPassportReference?: string; + + visaType: string; + visaNumber: string; + visaIssueDate: Date; + visaExpiryDate: Date; + visaIssuingPlace: string; + visaStayUntilDate: Date; + tm6Number: string; + entryDate: Date; + workerStatus: string; subDistrictId?: string | null; districtId?: string | null; @@ -104,7 +116,6 @@ type EmployeeUpdate = { customerBranchId?: string; status?: "ACTIVE" | "INACTIVE"; - code?: string; nrcNo?: string; dateOfBirth?: Date; @@ -119,11 +130,24 @@ type EmployeeUpdate = { addressEN?: string; address?: string; zipCode?: string; - email?: string; - telephoneNo?: string; - arrivalBarricade?: string; - arrivalCardNo?: string; + passportType?: string; + passportNumber?: string; + passportIssueDate?: Date; + passportExpiryDate?: Date; + passportIssuingCountry?: string; + passportIssuingPlace?: string; + previousPassportReference?: string; + + visaType?: string; + visaNumber?: string; + visaIssueDate?: Date; + visaExpiryDate?: Date; + visaIssuingPlace?: string; + visaStayUntilDate?: Date; + tm6Number?: string; + entryDate?: Date; + workerStatus?: string; subDistrictId?: string | null; districtId?: string | null; @@ -189,7 +213,6 @@ export class EmployeeController extends Controller { { firstNameEN: { contains: query }, zipCode }, { lastName: { contains: query }, zipCode }, { lastNameEN: { contains: query }, zipCode }, - { email: { contains: query }, zipCode }, ], } satisfies Prisma.EmployeeWhereInput;