From b7220687586b455e26560b3120ac5b34306caa86 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 15 Jun 2026 17:17:36 +0700 Subject: [PATCH] =?UTF-8?q?migrate=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=E0=B8=9A?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B8=97=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B9=82=E0=B8=84=E0=B8=A3=E0=B8=87=E0=B8=AA=E0=B8=A3?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87=20orgRoot,=20orgChild1,=20...,=20or?= =?UTF-8?q?gChild4=20#252?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrgChild1Controller.ts | 2 ++ src/controllers/OrgChild2Controller.ts | 2 ++ src/controllers/OrgChild3Controller.ts | 2 ++ src/controllers/OrgChild4Controller.ts | 2 ++ src/controllers/OrgRootController.ts | 2 ++ src/entities/OrgChild1.ts | 14 ++++++++++++ src/entities/OrgChild2.ts | 14 ++++++++++++ src/entities/OrgChild3.ts | 14 ++++++++++++ src/entities/OrgChild4.ts | 14 ++++++++++++ src/entities/OrgRoot.ts | 14 ++++++++++++ ...929-update_root_c1_to_c4_add_field_code.ts | 22 +++++++++++++++++++ 11 files changed, 102 insertions(+) create mode 100644 src/migration/1781517610929-update_root_c1_to_c4_add_field_code.ts diff --git a/src/controllers/OrgChild1Controller.ts b/src/controllers/OrgChild1Controller.ts index 6e44af05..d59ce669 100644 --- a/src/controllers/OrgChild1Controller.ts +++ b/src/controllers/OrgChild1Controller.ts @@ -74,6 +74,7 @@ export class OrgChild1Controller { DIVISION_CODE: orgChild1.DIVISION_CODE, SECTION_CODE: orgChild1.SECTION_CODE, JOB_CODE: orgChild1.JOB_CODE, + CHILD1_CODE: orgChild1.CHILD1_CODE, orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code, }; return new HttpSuccess(getOrgChild1); @@ -346,6 +347,7 @@ export class OrgChild1Controller { DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null, SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null, JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null, + CHILD1_CODE: requestBody.CHILD1_CODE != null ? requestBody.CHILD1_CODE : _null, isOfficer: requestBody.isOfficer, isInformation: requestBody.isInformation, orgChild1PhoneEx: requestBody.orgChild1PhoneEx, diff --git a/src/controllers/OrgChild2Controller.ts b/src/controllers/OrgChild2Controller.ts index 28ce564f..1cc4186d 100644 --- a/src/controllers/OrgChild2Controller.ts +++ b/src/controllers/OrgChild2Controller.ts @@ -85,6 +85,7 @@ export class OrgChild2Controller extends Controller { DIVISION_CODE: orgChild2.DIVISION_CODE, SECTION_CODE: orgChild2.SECTION_CODE, JOB_CODE: orgChild2.JOB_CODE, + CHILD2_CODE: orgChild2.CHILD2_CODE, orgCode: orgChild2.orgRoot.orgRootCode + orgChild2.orgChild2Code, }; return new HttpSuccess(getOrgChild2); @@ -252,6 +253,7 @@ export class OrgChild2Controller extends Controller { DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null, SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null, JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null, + CHILD2_CODE: requestBody.CHILD2_CODE != null ? requestBody.CHILD2_CODE : _null, orgChild2PhoneEx: requestBody.orgChild2PhoneEx, orgChild2PhoneIn: requestBody.orgChild2PhoneIn, orgChild2Fax: requestBody.orgChild2Fax, diff --git a/src/controllers/OrgChild3Controller.ts b/src/controllers/OrgChild3Controller.ts index 4ed10804..a3861d55 100644 --- a/src/controllers/OrgChild3Controller.ts +++ b/src/controllers/OrgChild3Controller.ts @@ -69,6 +69,7 @@ export class OrgChild3Controller { DIVISION_CODE: orgChild3.DIVISION_CODE, SECTION_CODE: orgChild3.SECTION_CODE, JOB_CODE: orgChild3.JOB_CODE, + CHILD3_CODE: orgChild3.CHILD3_CODE, orgCode: orgChild3.orgRoot.orgRootCode + orgChild3.orgChild3Code, }; return new HttpSuccess(getOrgChild3); @@ -207,6 +208,7 @@ export class OrgChild3Controller { DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null, SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null, JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null, + CHILD3_CODE: requestBody.CHILD3_CODE != null ? requestBody.CHILD3_CODE : _null, orgChild3PhoneEx: requestBody.orgChild3PhoneEx, orgChild3PhoneIn: requestBody.orgChild3PhoneIn, orgChild3Fax: requestBody.orgChild3Fax, diff --git a/src/controllers/OrgChild4Controller.ts b/src/controllers/OrgChild4Controller.ts index e18c15f9..eb044bbc 100644 --- a/src/controllers/OrgChild4Controller.ts +++ b/src/controllers/OrgChild4Controller.ts @@ -82,6 +82,7 @@ export class OrgChild4Controller extends Controller { DIVISION_CODE: orgChild4.DIVISION_CODE, SECTION_CODE: orgChild4.SECTION_CODE, JOB_CODE: orgChild4.JOB_CODE, + CHILD4_CODE: orgChild4.CHILD4_CODE, orgCode: orgChild4.orgRoot.orgRootCode + orgChild4.orgChild4Code, }; return new HttpSuccess(getOrgChild4); @@ -254,6 +255,7 @@ export class OrgChild4Controller extends Controller { DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null, SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null, JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null, + CHILD4_CODE: requestBody.CHILD4_CODE != null ? requestBody.CHILD4_CODE : _null, orgChild4PhoneEx: requestBody.orgChild4PhoneEx, orgChild4PhoneIn: requestBody.orgChild4PhoneIn, orgChild4Fax: requestBody.orgChild4Fax, diff --git a/src/controllers/OrgRootController.ts b/src/controllers/OrgRootController.ts index 45bf1436..69c5bba8 100644 --- a/src/controllers/OrgRootController.ts +++ b/src/controllers/OrgRootController.ts @@ -83,6 +83,7 @@ export class OrgRootController extends Controller { DIVISION_CODE: orgRoot.DIVISION_CODE, SECTION_CODE: orgRoot.SECTION_CODE, JOB_CODE: orgRoot.JOB_CODE, + ROOT_CODE: orgRoot.ROOT_CODE, orgCode: orgRoot.orgRootCode + "00", }; return new HttpSuccess(getOrgRoot); @@ -350,6 +351,7 @@ export class OrgRootController extends Controller { DIVISION_CODE: requestBody.DIVISION_CODE != null ? requestBody.DIVISION_CODE : _null, SECTION_CODE: requestBody.SECTION_CODE != null ? requestBody.SECTION_CODE : _null, JOB_CODE: requestBody.JOB_CODE != null ? requestBody.JOB_CODE : _null, + ROOT_CODE: requestBody.ROOT_CODE != null ? requestBody.ROOT_CODE : _null, }); await this.orgRootRepository.save(orgRoot, { data: request }); setLogDataDiff(request, { before, after: orgRoot }); diff --git a/src/entities/OrgChild1.ts b/src/entities/OrgChild1.ts index e322df8b..b211acf8 100644 --- a/src/entities/OrgChild1.ts +++ b/src/entities/OrgChild1.ts @@ -174,6 +174,14 @@ export class OrgChild1 extends EntityBase { }) JOB_CODE: string; + @Column({ + nullable: true, + length: 3, + comment: "CHILD1_CODE", + default: null, + }) + CHILD1_CODE: string; + @ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s) @JoinColumn({ name: "orgRootId" }) orgRoot: OrgRoot; @@ -228,6 +236,9 @@ export class CreateOrgChild1 { @Column() JOB_CODE?: string | null; + @Column() + CHILD1_CODE?: string | null; + @Column() orgChild1PhoneEx?: string; @@ -283,6 +294,9 @@ export class UpdateOrgChild1 { @Column() JOB_CODE?: string | null; + @Column() + CHILD1_CODE?: string | null; + @Column() orgChild1PhoneEx?: string; diff --git a/src/entities/OrgChild2.ts b/src/entities/OrgChild2.ts index b2ed6a0c..1abf8b61 100644 --- a/src/entities/OrgChild2.ts +++ b/src/entities/OrgChild2.ts @@ -146,6 +146,14 @@ export class OrgChild2 extends EntityBase { }) JOB_CODE: string; + @Column({ + nullable: true, + length: 3, + comment: "CHILD2_CODE", + default: null, + }) + CHILD2_CODE: string; + @Column({ nullable: true, length: 40, @@ -222,6 +230,9 @@ export class CreateOrgChild2 { @Column() JOB_CODE?: string; + @Column() + CHILD2_CODE?: string; + @Column() orgChild2PhoneEx?: string; @@ -269,6 +280,9 @@ export class UpdateOrgChild2 { @Column() JOB_CODE?: string | null; + @Column() + CHILD2_CODE?: string | null; + @Column() orgChild2PhoneEx?: string; diff --git a/src/entities/OrgChild3.ts b/src/entities/OrgChild3.ts index 4c376fb6..6fbc1e72 100644 --- a/src/entities/OrgChild3.ts +++ b/src/entities/OrgChild3.ts @@ -153,6 +153,14 @@ export class OrgChild3 extends EntityBase { }) JOB_CODE: string; + @Column({ + nullable: true, + length: 3, + comment: "CHILD3_CODE", + default: null, + }) + CHILD3_CODE: string; + @Column({ nullable: true, length: 40, @@ -230,6 +238,9 @@ export class CreateOrgChild3 { @Column() JOB_CODE?: string; + @Column() + CHILD3_CODE?: string; + @Column() orgChild3PhoneEx?: string; @@ -279,6 +290,9 @@ export class UpdateOrgChild3 { @Column() JOB_CODE?: string | null; + @Column() + CHILD3_CODE?: string | null; + @Column() orgChild3PhoneEx?: string; diff --git a/src/entities/OrgChild4.ts b/src/entities/OrgChild4.ts index 314c9393..d0a28a27 100644 --- a/src/entities/OrgChild4.ts +++ b/src/entities/OrgChild4.ts @@ -158,6 +158,14 @@ export class OrgChild4 extends EntityBase { }) JOB_CODE: string; + @Column({ + nullable: true, + length: 3, + comment: "CHILD4_CODE", + default: null, + }) + CHILD4_CODE: string; + @Column({ nullable: true, length: 40, @@ -236,6 +244,9 @@ export class CreateOrgChild4 { @Column() JOB_CODE?: string; + @Column() + CHILD4_CODE?: string; + @Column() orgChild4PhoneEx?: string; @@ -283,6 +294,9 @@ export class UpdateOrgChild4 { @Column() JOB_CODE?: string | null; + @Column() + CHILD4_CODE?: string | null; + @Column() orgChild4PhoneEx?: string; diff --git a/src/entities/OrgRoot.ts b/src/entities/OrgRoot.ts index 3aefad6e..d474a1fe 100644 --- a/src/entities/OrgRoot.ts +++ b/src/entities/OrgRoot.ts @@ -166,6 +166,14 @@ export class OrgRoot extends EntityBase { }) JOB_CODE: string; + @Column({ + nullable: true, + length: 3, + comment: "ROOT_CODE", + default: null, + }) + ROOT_CODE: string; + @ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots) @JoinColumn({ name: "orgRevisionId" }) orgRevision: OrgRevision; @@ -226,6 +234,9 @@ export class CreateOrgRoot { @Column() JOB_CODE?: string; + @Column() + ROOT_CODE?: string; + @Column() orgRootPhoneEx?: string; @@ -281,6 +292,9 @@ export class UpdateOrgRoot { @Column() JOB_CODE?: string | null; + @Column() + ROOT_CODE?: string | null; + @Column() orgRootPhoneEx?: string; diff --git a/src/migration/1781517610929-update_root_c1_to_c4_add_field_code.ts b/src/migration/1781517610929-update_root_c1_to_c4_add_field_code.ts new file mode 100644 index 00000000..157ab487 --- /dev/null +++ b/src/migration/1781517610929-update_root_c1_to_c4_add_field_code.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateRootC1ToC4AddFieldCode1781517610929 implements MigrationInterface { + name = 'UpdateRootC1ToC4AddFieldCode1781517610929' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD \`CHILD4_CODE\` varchar(3) NULL COMMENT 'CHILD4_CODE'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD \`CHILD3_CODE\` varchar(3) NULL COMMENT 'CHILD3_CODE'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD \`CHILD2_CODE\` varchar(3) NULL COMMENT 'CHILD2_CODE'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD \`CHILD1_CODE\` varchar(3) NULL COMMENT 'CHILD1_CODE'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`ROOT_CODE\` varchar(3) NULL COMMENT 'ROOT_CODE'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`ROOT_CODE\``); + await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP COLUMN \`CHILD1_CODE\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP COLUMN \`CHILD2_CODE\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP COLUMN \`CHILD3_CODE\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP COLUMN \`CHILD4_CODE\``); + } + +}