From e96a05e3ad144d2c295f60a8ebd4d5edfebb431e Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:12:10 +0700 Subject: [PATCH] feat: update schema --- .../20240610061629_add_field/migration.sql | 30 +++++++++++++++++++ .../migration.sql | 10 +++++++ prisma/schema.prisma | 15 +++++++--- src/controllers/employee-controller.ts | 22 +++++++++++--- .../employee-other-info-controller.ts | 22 +++++++++++--- 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 prisma/migrations/20240610061629_add_field/migration.sql create mode 100644 prisma/migrations/20240610062435_fix_prev_typo/migration.sql diff --git a/prisma/migrations/20240610061629_add_field/migration.sql b/prisma/migrations/20240610061629_add_field/migration.sql new file mode 100644 index 0000000..bea038e --- /dev/null +++ b/prisma/migrations/20240610061629_add_field/migration.sql @@ -0,0 +1,30 @@ +/* + Warnings: + + - You are about to drop the column `birthPlace` on the `EmployeeOtherInfo` table. All the data in the column will be lost. + - You are about to drop the column `fatherFullName` on the `EmployeeOtherInfo` table. All the data in the column will be lost. + - You are about to drop the column `motherFullName` on the `EmployeeOtherInfo` table. All the data in the column will be lost. + - Added the required column `birthPlaceEN` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `fatherFirstName` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `fatherFirstNameEN` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `fatherLastName` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `fatherLastNameEN` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `motherFirstName` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `motherFirstNameEN` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `motherLastName` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + - Added the required column `motherLastNameEN` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "EmployeeOtherInfo" DROP COLUMN "birthPlace", +DROP COLUMN "fatherFullName", +DROP COLUMN "motherFullName", +ADD COLUMN "birthPlaceEN" TEXT NOT NULL, +ADD COLUMN "fatherFirstName" TEXT NOT NULL, +ADD COLUMN "fatherFirstNameEN" TEXT NOT NULL, +ADD COLUMN "fatherLastName" TEXT NOT NULL, +ADD COLUMN "fatherLastNameEN" TEXT NOT NULL, +ADD COLUMN "motherFirstName" TEXT NOT NULL, +ADD COLUMN "motherFirstNameEN" TEXT NOT NULL, +ADD COLUMN "motherLastName" TEXT NOT NULL, +ADD COLUMN "motherLastNameEN" TEXT NOT NULL; diff --git a/prisma/migrations/20240610062435_fix_prev_typo/migration.sql b/prisma/migrations/20240610062435_fix_prev_typo/migration.sql new file mode 100644 index 0000000..23b59f5 --- /dev/null +++ b/prisma/migrations/20240610062435_fix_prev_typo/migration.sql @@ -0,0 +1,10 @@ +/* + Warnings: + + - You are about to drop the column `birthPlaceEN` on the `EmployeeOtherInfo` table. All the data in the column will be lost. + - Added the required column `birthPlace` to the `EmployeeOtherInfo` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "EmployeeOtherInfo" DROP COLUMN "birthPlaceEN", +ADD COLUMN "birthPlace" TEXT NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a8d0dd9..f5f8e21 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -501,10 +501,17 @@ model EmployeeOtherInfo { employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) employeeId String - citizenId String - fatherFullName String - motherFullName String - birthPlace String + citizenId String + birthPlace String + fatherFirstName String + fatherLastName String + motherFirstName String + motherLastName String + + fatherFirstNameEN String + fatherLastNameEN String + motherFirstNameEN String + motherLastNameEN String createdBy String? createdAt DateTime @default(now()) diff --git a/src/controllers/employee-controller.ts b/src/controllers/employee-controller.ts index d5fd5ce..c1745f7 100644 --- a/src/controllers/employee-controller.ts +++ b/src/controllers/employee-controller.ts @@ -86,8 +86,15 @@ type EmployeeCreate = { employeeOtherInfo: { citizenId: string; - fatherFullName: string; - motherFullName: string; + fatherFirstName: string; + fatherLastName: string; + motherFirstName: string; + motherLastName: string; + + fatherFirstNameEN: string; + fatherLastNameEN: string; + motherFirstNameEN: string; + motherLastNameEN: string; birthPlace: string; }; }; @@ -150,8 +157,15 @@ type EmployeeUpdate = { employeeOtherInfo: { citizenId: string; - fatherFullName: string; - motherFullName: string; + fatherFirstName: string; + fatherLastName: string; + motherFirstName: string; + motherLastName: string; + + fatherFirstNameEN: string; + fatherLastNameEN: string; + motherFirstNameEN: string; + motherLastNameEN: string; birthPlace: string; }; }; diff --git a/src/controllers/employee-other-info-controller.ts b/src/controllers/employee-other-info-controller.ts index e134ec5..c866678 100644 --- a/src/controllers/employee-other-info-controller.ts +++ b/src/controllers/employee-other-info-controller.ts @@ -21,15 +21,29 @@ import { RequestWithUser } from "../interfaces/user"; type EmployeeOtherInfoCreate = { citizenId: string; - fatherFullName: string; - motherFullName: string; + fatherFirstName: string; + fatherLastName: string; + motherFirstName: string; + motherLastName: string; + + fatherFirstNameEN: string; + fatherLastNameEN: string; + motherFirstNameEN: string; + motherLastNameEN: string; birthPlace: string; }; type EmployeeOtherInfoUpdate = { citizenId: string; - fatherFullName: string; - motherFullName: string; + fatherFirstName: string; + fatherLastName: string; + motherFirstName: string; + motherLastName: string; + + fatherFirstNameEN: string; + fatherLastNameEN: string; + motherFirstNameEN: string; + motherLastNameEN: string; birthPlace: string; };