diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index c7de3004..7b160685 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -22,7 +22,7 @@ import HttpSuccess from "../interfaces/http-success"; import { CreateOrgChild1, OrgChild1 } from "../entities/OrgChild1"; import HttpError from "../interfaces/http-error"; import HttpStatusCode from "../interfaces/http-status"; -import { In, Not } from "typeorm"; +import { In, IsNull, Not } from "typeorm"; import { OrgRoot } from "../entities/OrgRoot"; import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; @@ -608,7 +608,7 @@ export class OrganizationController extends Controller { "orgRoot.orgRevisionId", "orgRoot.orgRootRank", ]) - .orderBy("orgRoot.createdAt", "ASC") + .orderBy("orgRoot.orgRootOrder", "ASC") .getMany(); const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null; @@ -629,7 +629,7 @@ export class OrganizationController extends Controller { "orgChild1.orgRootId", "orgChild1.orgChild1Rank", ]) - .orderBy("orgChild1.createdAt", "ASC") + .orderBy("orgChild1.orgChild1Order", "ASC") .getMany() : []; @@ -650,10 +650,9 @@ export class OrganizationController extends Controller { "orgChild2.orgChild2Fax", "orgChild2.orgRootId", "orgChild2.orgChild2Rank", - "orgChild2.orgChild1Id", ]) - .orderBy("orgChild2.createdAt", "ASC") + .orderBy("orgChild2.orgChild2Order", "ASC") .getMany() : []; @@ -674,10 +673,9 @@ export class OrganizationController extends Controller { "orgChild3.orgChild3Fax", "orgChild3.orgRootId", "orgChild3.orgChild3Rank", - "orgChild3.orgChild2Id", ]) - .orderBy("orgChild3.createdAt", "ASC") + .orderBy("orgChild3.orgChild3Order", "ASC") .getMany() : []; @@ -698,10 +696,9 @@ export class OrganizationController extends Controller { "orgChild4.orgChild4Fax", "orgChild4.orgRootId", "orgChild4.orgChild4Rank", - "orgChild4.orgChild3Id", ]) - .orderBy("orgChild4.createdAt", "ASC") + .orderBy("orgChild4.orgChild4Order", "ASC") .getMany() : []; @@ -869,7 +866,11 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child1"); } const datas = await this.child1Repository.find({ - where: { isAncestorDNA: orgChild1.isAncestorDNA }, + where: [ + { isAncestorDNA: orgChild1.isAncestorDNA }, + { isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") }, + { isAncestorDNA: Not(IsNull()) }, + ], relations: ["orgRevision"], order: { lastUpdatedAt: "DESC" }, }); @@ -888,7 +889,11 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child2"); } const datas = await this.child2Repository.find({ - where: { isAncestorDNA: orgChild2.isAncestorDNA }, + where: [ + { isAncestorDNA: orgChild2.isAncestorDNA }, + { isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") }, + { isAncestorDNA: Not(IsNull()) }, + ], relations: ["orgRevision"], order: { lastUpdatedAt: "DESC" }, }); @@ -907,7 +912,11 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child3"); } const datas = await this.child3Repository.find({ - where: { isAncestorDNA: orgChild3.isAncestorDNA }, + where: [ + { isAncestorDNA: orgChild3.isAncestorDNA }, + { isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") }, + { isAncestorDNA: Not(IsNull()) }, + ], relations: ["orgRevision"], order: { lastUpdatedAt: "DESC" }, }); @@ -926,7 +935,11 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child4"); } const datas = await this.child4Repository.find({ - where: { isAncestorDNA: orgChild4.isAncestorDNA }, + where: [ + { isAncestorDNA: orgChild4.isAncestorDNA }, + { isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") }, + { isAncestorDNA: Not(IsNull()) }, + ], relations: ["orgRevision"], order: { lastUpdatedAt: "DESC" }, }); @@ -945,7 +958,11 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Root"); } const datas = await this.orgRootRepository.find({ - where: { isAncestorDNA: orgRoot.isAncestorDNA }, + where: [ + { isAncestorDNA: orgRoot.isAncestorDNA }, + { isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") }, + { isAncestorDNA: Not(IsNull()) }, + ], relations: ["orgRevision"], order: { lastUpdatedAt: "DESC" }, }); diff --git a/src/entities/OrgChild1.ts b/src/entities/OrgChild1.ts index ef1c78c5..90e832dc 100644 --- a/src/entities/OrgChild1.ts +++ b/src/entities/OrgChild1.ts @@ -20,7 +20,7 @@ export class OrgChild1 extends EntityBase { nullable: true, comment: "ชื่อส่วนราชการ", length: 255, - default: "string", + default: null, }) orgChild1Name: string; @@ -28,7 +28,7 @@ export class OrgChild1 extends EntityBase { nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, - default: "string", + default: null, }) orgChild1ShortName: string; @@ -36,7 +36,7 @@ export class OrgChild1 extends EntityBase { nullable: true, comment: "รหัสส่วนราชการ", length: 8, - default: "string", + default: null, }) orgChild1Code: string; @@ -45,12 +45,14 @@ export class OrgChild1 extends EntityBase { comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild1Rank, + default: null, }) orgChild1Rank: OrgChild1Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", + default: null, }) orgChild1Order: number; @@ -58,6 +60,7 @@ export class OrgChild1 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", + default: null, }) orgChild1PhoneEx: string; @@ -65,6 +68,7 @@ export class OrgChild1 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", + default: null, }) orgChild1PhoneIn: string; @@ -72,24 +76,24 @@ export class OrgChild1 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรสาร", + default: null, }) orgChild1Fax: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRootId: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; @Column({ + nullable: true, length: 40, - default: "00000000-0000-0000-0000-000000000000", + default: null, }) isAncestorDNA: string; diff --git a/src/entities/OrgChild2.ts b/src/entities/OrgChild2.ts index 8c66b684..ced40f3f 100644 --- a/src/entities/OrgChild2.ts +++ b/src/entities/OrgChild2.ts @@ -7,7 +7,6 @@ import { OrgChild4 } from "./OrgChild4"; import { OrgRevision } from "./OrgRevision"; import { PosMaster } from "./PosMaster"; -// ENUM orgChild2Rank enum OrgChild2Rank { DEPARTMENT = "DEPARTMENT", OFFICE = "OFFICE", @@ -16,18 +15,11 @@ enum OrgChild2Rank { } @Entity("orgChild2") export class OrgChild2 extends EntityBase { - // @Column({ - // comment: "", - // length: 40, - // default: "00000000-0000-0000-0000-000000000000", - // }) - // orgChild2Id: string; - @Column({ nullable: true, comment: "ชื่อส่วนราชการ", length: 255, - default: "string", + default: null, }) orgChild2Name: string; @@ -35,7 +27,7 @@ export class OrgChild2 extends EntityBase { nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, - default: "string", + default: null, }) orgChild2ShortName: string; @@ -43,7 +35,7 @@ export class OrgChild2 extends EntityBase { nullable: true, comment: "รหัสส่วนราชการ", length: 8, - default: "string", + default: null, }) orgChild2Code: string; @@ -52,13 +44,14 @@ export class OrgChild2 extends EntityBase { comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild2Rank, - // default: OrgChild2Rank.DEPARTMENT, + default: null, }) orgChild2Rank: OrgChild2Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", + default: null, }) orgChild2Order: number; @@ -66,6 +59,7 @@ export class OrgChild2 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", + default: null, }) orgChild2PhoneEx: string; @@ -73,6 +67,7 @@ export class OrgChild2 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", + default: null, }) orgChild2PhoneIn: string; @@ -80,30 +75,29 @@ export class OrgChild2 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรสาร", + default: null, }) orgChild2Fax: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRootId: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild1Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; @Column({ + nullable: true, length: 40, - default: "00000000-0000-0000-0000-000000000000", + default: null, }) isAncestorDNA: string; diff --git a/src/entities/OrgChild3.ts b/src/entities/OrgChild3.ts index f666c753..55208d70 100644 --- a/src/entities/OrgChild3.ts +++ b/src/entities/OrgChild3.ts @@ -20,7 +20,7 @@ export class OrgChild3 extends EntityBase { nullable: true, comment: "ชื่อส่วนราชการ", length: 255, - default: "string", + default: null, }) orgChild3Name: string; @@ -28,7 +28,7 @@ export class OrgChild3 extends EntityBase { nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, - default: "string", + default: null, }) orgChild3ShortName: string; @@ -36,7 +36,7 @@ export class OrgChild3 extends EntityBase { nullable: true, comment: "รหัสส่วนราชการ", length: 8, - default: "string", + default: null, }) orgChild3Code: string; @@ -45,12 +45,14 @@ export class OrgChild3 extends EntityBase { comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild3Rank, + default: null, }) orgChild3Rank: OrgChild3Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", + default: null, }) orgChild3Order: number; @@ -58,6 +60,7 @@ export class OrgChild3 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", + default: null, }) orgChild3PhoneEx: string; @@ -65,6 +68,7 @@ export class OrgChild3 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", + default: null, }) orgChild3PhoneIn: string; @@ -72,36 +76,34 @@ export class OrgChild3 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรสาร", + default: null, }) orgChild3Fax: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRootId: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild1Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild2Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; @Column({ + nullable: true, length: 40, - default: "00000000-0000-0000-0000-000000000000", + default: null, }) isAncestorDNA: string; diff --git a/src/entities/OrgChild4.ts b/src/entities/OrgChild4.ts index a47803e5..8e099701 100644 --- a/src/entities/OrgChild4.ts +++ b/src/entities/OrgChild4.ts @@ -6,7 +6,7 @@ import { OrgChild2 } from "./OrgChild2"; import { OrgChild3 } from "./OrgChild3"; import { OrgRevision } from "./OrgRevision"; import { PosMaster } from "./PosMaster"; -// ENUM orgChild4Rank + enum OrgChild4Rank { DEPARTMENT = "DEPARTMENT", OFFICE = "OFFICE", @@ -15,18 +15,11 @@ enum OrgChild4Rank { } @Entity("orgChild4") export class OrgChild4 extends EntityBase { - // @Column({ - // comment: "", - // length: 40, - // default: "00000000-0000-0000-0000-000000000000", - // }) - // orgChild4Id: string; - @Column({ nullable: true, comment: "ชื่อส่วนราชการ", length: 255, - default: "string", + default: null, }) orgChild4Name: string; @@ -34,7 +27,7 @@ export class OrgChild4 extends EntityBase { nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, - default: "string", + default: null, }) orgChild4ShortName: string; @@ -42,7 +35,7 @@ export class OrgChild4 extends EntityBase { nullable: true, comment: "รหัสส่วนราชการ", length: 8, - default: "string", + default: null, }) orgChild4Code: string; @@ -51,13 +44,14 @@ export class OrgChild4 extends EntityBase { comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild4Rank, - // default: OrgChild4Rank.DEPARTMENT, + default: null, }) orgChild4Rank: OrgChild4Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", + default: null, }) orgChild4Order: number; @@ -65,6 +59,7 @@ export class OrgChild4 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", + default: null, }) orgChild4PhoneEx: string; @@ -72,6 +67,7 @@ export class OrgChild4 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", + default: null, }) orgChild4PhoneIn: string; @@ -79,42 +75,39 @@ export class OrgChild4 extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรสาร", + default: null, }) orgChild4Fax: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRootId: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild1Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild2Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgChild3Id: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; @Column({ + nullable: true, length: 40, - default: "00000000-0000-0000-0000-000000000000", + default: null, }) isAncestorDNA: string; @@ -139,7 +132,7 @@ export class OrgChild4 extends EntityBase { orgChild3: OrgChild3; @OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild4) - posMasters: PosMaster[] + posMasters: PosMaster[]; } export class CreateOrgChild4 { diff --git a/src/entities/OrgRevision.ts b/src/entities/OrgRevision.ts index 68a31b84..36d502a2 100644 --- a/src/entities/OrgRevision.ts +++ b/src/entities/OrgRevision.ts @@ -9,22 +9,14 @@ import { OrgChild4 } from "./OrgChild4"; @Entity("orgRevision") export class OrgRevision extends EntityBase { - // @Column({ - // comment: "", - // length: 40, - // default: "00000000-0000-0000-0000-000000000000", - // }) - // orgRevisionId: string; - @Column({ comment: "", length: 255, - default: "string", + default: null, }) orgRevisionName: string; @Column({ - nullable: true, comment: "", default: false, }) @@ -34,6 +26,7 @@ export class OrgRevision extends EntityBase { nullable: true, type: "datetime", comment: "", + default: null, }) orgRevisionCreatedAt: Date; @@ -41,11 +34,11 @@ export class OrgRevision extends EntityBase { nullable: true, type: "datetime", comment: "เวลาเผยแพร่", + default: null, }) orgPublishDate: Date; @Column({ - nullable: true, comment: "", default: false, }) diff --git a/src/entities/OrgRoot.ts b/src/entities/OrgRoot.ts index 4c5e62f8..5137b28e 100644 --- a/src/entities/OrgRoot.ts +++ b/src/entities/OrgRoot.ts @@ -7,7 +7,6 @@ import { OrgChild3 } from "./OrgChild3"; import { OrgChild4 } from "./OrgChild4"; import { PosMaster } from "./PosMaster"; -// ENUM orgRootRank enum OrgRootRank { DEPARTMENT = "DEPARTMENT", OFFICE = "OFFICE", @@ -21,7 +20,7 @@ export class OrgRoot extends EntityBase { nullable: true, comment: "ชื่อหน่วยงาน", length: 255, - default: "string", + default: null, }) orgRootName: string; @@ -29,7 +28,7 @@ export class OrgRoot extends EntityBase { nullable: true, comment: "ชื่อย่อหน่วยงาน", length: 16, - default: "string", + default: null, }) orgRootShortName: string; @@ -37,7 +36,7 @@ export class OrgRoot extends EntityBase { nullable: true, comment: "รหัสหน่วยงาน", length: 8, - default: "string", + default: null, }) orgRootCode: string; @@ -46,13 +45,14 @@ export class OrgRoot extends EntityBase { comment: "ระดับของหน่วยงาน", type: "enum", enum: OrgRootRank, - default: OrgRootRank.DEPARTMENT, + default: null, }) orgRootRank: OrgRootRank; @Column({ nullable: true, comment: "ลำดับที่ของหน่วยงาน", + default: null, }) orgRootOrder: number; @@ -60,6 +60,7 @@ export class OrgRoot extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", + default: null, }) orgRootPhoneEx: string; @@ -67,6 +68,7 @@ export class OrgRoot extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", + default: null, }) orgRootPhoneIn: string; @@ -74,18 +76,19 @@ export class OrgRoot extends EntityBase { nullable: true, length: 64, comment: "หมายเลขโทรสาร", + default: null, }) orgRootFax: string; @Column({ + nullable: true, length: 40, - default: "00000000-0000-0000-0000-000000000000", + default: null, }) isAncestorDNA: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; diff --git a/src/entities/PosDict.ts b/src/entities/PosDict.ts index f87bdbff..f31c32e8 100644 --- a/src/entities/PosDict.ts +++ b/src/entities/PosDict.ts @@ -10,7 +10,7 @@ export class PosDict extends EntityBase { nullable: true, comment: "ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)", length: 255, - default: "string", + default: null, }) posDictName: string; @@ -18,21 +18,19 @@ export class PosDict extends EntityBase { nullable: true, comment: "สายงาน", length: 255, - default: "string", + default: null, }) posDictField: string; @Column({ length: 40, comment: "ตำแหน่งประเภท", - default: "00000000-0000-0000-0000-000000000000", }) posTypeId: string; @Column({ length: 40, comment: "ระดับตำแหน่ง", - default: "00000000-0000-0000-0000-000000000000", }) posLevelId: string; @@ -40,7 +38,7 @@ export class PosDict extends EntityBase { nullable: true, length: 40, comment: "ตำแหน่งทางการบริหาร", - default: "00000000-0000-0000-0000-000000000000", + default: null, }) posExecutiveId: string; @@ -48,7 +46,7 @@ export class PosDict extends EntityBase { nullable: true, length: 255, comment: "ด้านทางการบริหาร", - default: "string", + default: null, }) posDictExecutiveField: string; @@ -56,7 +54,7 @@ export class PosDict extends EntityBase { nullable: true, length: 255, comment: "ด้าน/สาขา", - default: "string", + default: null, }) posDictArea: string; diff --git a/src/entities/PosExecutive.ts b/src/entities/PosExecutive.ts index bc369075..325383c9 100644 --- a/src/entities/PosExecutive.ts +++ b/src/entities/PosExecutive.ts @@ -9,13 +9,14 @@ export class PosExecutive extends EntityBase { nullable: true, comment: "ชื่อตำแหน่งทางการบริหาร", length: 255, - default: "string", + default: null, }) posExecutiveName: string; @Column({ nullable: true, comment: "ลำดับความสำคัญ", + default: null, }) posExecutivePriority: number; @@ -34,4 +35,4 @@ export class CreatePosExecutive { posExecutivePriority: number; } -export type UpdatePosExecutive = Partial; \ No newline at end of file +export type UpdatePosExecutive = Partial; diff --git a/src/entities/PosLevel.ts b/src/entities/PosLevel.ts index af1948f7..b0659e22 100644 --- a/src/entities/PosLevel.ts +++ b/src/entities/PosLevel.ts @@ -3,7 +3,6 @@ import { EntityBase } from "./base/Base"; import { PosType } from "./PosType"; import { Position } from "./Position"; import { PosDict } from "./PosDict"; -// ENUM PosLevelAuthority enum PosLevelAuthority { HEAD = "HEAD", DEPUTY = "DEPUTY", @@ -15,13 +14,14 @@ export class PosLevel extends EntityBase { nullable: true, comment: "ชื่อระดับตำแหน่ง", length: 255, - default: "string", + default: null, }) posLevelName: string; @Column({ nullable: true, comment: "ระดับของระดับตำแหน่ง", + default: null, }) posLevelRank: number; @@ -31,13 +31,13 @@ export class PosLevel extends EntityBase { "ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ", type: "enum", enum: PosLevelAuthority, + default: null, }) posLevelAuthority: PosLevelAuthority; @Column({ length: 40, comment: "เป็นระดับของประเภทตำแหน่งใด", - default: "00000000-0000-0000-0000-000000000000", }) posTypeId: string; diff --git a/src/entities/PosMaster.ts b/src/entities/PosMaster.ts index a34ce8a1..0567854c 100644 --- a/src/entities/PosMaster.ts +++ b/src/entities/PosMaster.ts @@ -20,13 +20,14 @@ export class PosMaster extends EntityBase { nullable: true, comment: "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)", length: 16, - default: "string", + default: null, }) posMasterNoPrefix: string; @Column({ nullable: true, comment: "เลขที่ตำแหน่ง เป็นตัวเลข", + default: null, }) posMasterNo: number; @@ -34,7 +35,7 @@ export class PosMaster extends EntityBase { nullable: true, comment: "Suffix หลังเลขที่ตำแหน่ง เช่น ช.", length: 16, - default: "string", + default: null, }) posMasterNoSuffix: string; @@ -42,6 +43,7 @@ export class PosMaster extends EntityBase { nullable: true, type: "datetime", comment: "วัน-เวลาที่สร้าง", + default: null, }) posMasterCreatedAt: Date; @@ -50,19 +52,21 @@ export class PosMaster extends EntityBase { comment: "รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้", length: 40, - default: "string", + default: null, }) - ancestorDNA: string; + isAncestorDNA: string; @Column({ nullable: true, comment: "ลำดับที่แสดงผล", + default: null, }) posMasterOrder: number; @Column({ nullable: true, comment: "ลำดับความสำคัญ", + default: null, }) posMasterPriority: number; @@ -71,6 +75,7 @@ export class PosMaster extends EntityBase { comment: "สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง", type: "enum", enum: PosMasterLine, + default: null, }) posMasterLine: PosMasterLine; @@ -114,7 +119,7 @@ export class PosMaster extends EntityBase { length: 40, comment: "คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้", - default: "string", + default: null, }) profileIdCurrentHolder: string; @@ -123,13 +128,12 @@ export class PosMaster extends EntityBase { length: 40, comment: "คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย", - default: "string", + default: null, }) profileIdNextHolder: string; @Column({ length: 40, - default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; //fk diff --git a/src/entities/PosType.ts b/src/entities/PosType.ts index 435fcc0f..ed6d8610 100644 --- a/src/entities/PosType.ts +++ b/src/entities/PosType.ts @@ -10,7 +10,7 @@ export class PosType extends EntityBase { nullable: true, comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)", length: 255, - default: "string", + default: null, }) posTypeName: string; @@ -18,6 +18,7 @@ export class PosType extends EntityBase { nullable: true, comment: "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4", + default: null, }) posTypeRank: number; @@ -39,4 +40,4 @@ export class CreatePosType { posTypeRank: number; } -export type UpdatePosType = Partial; \ No newline at end of file +export type UpdatePosType = Partial; diff --git a/src/entities/Position.ts b/src/entities/Position.ts index 9904c07d..85c336c3 100644 --- a/src/entities/Position.ts +++ b/src/entities/Position.ts @@ -11,7 +11,7 @@ export class Position extends EntityBase { nullable: true, comment: "ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)", length: 255, - default: "string", + default: null, }) positionName: string; @@ -19,21 +19,19 @@ export class Position extends EntityBase { nullable: true, comment: "สายงาน", length: 45, - default: "string", + default: null, }) positionField: string; @Column({ length: 40, comment: "ประเภทตำแหน่ง", - default: "00000000-0000-0000-0000-000000000000", }) posTypeId: string; @Column({ length: 40, comment: "ระดับตำแหน่ง", - default: "00000000-0000-0000-0000-000000000000", }) posLevelId: string; @@ -41,7 +39,7 @@ export class Position extends EntityBase { nullable: true, length: 40, comment: "ตำแหน่งทางการบริหาร", - default: "00000000-0000-0000-0000-000000000000", + default: null, }) posExecutiveId: string; @@ -49,7 +47,7 @@ export class Position extends EntityBase { nullable: true, comment: "ด้านทางการบริหาร", length: 255, - default: "string", + default: null, }) positionExecutiveField: string; @@ -57,20 +55,19 @@ export class Position extends EntityBase { nullable: true, comment: "ด้าน/สาขา", length: 255, - default: "string", + default: null, }) positionArea: string; @Column({ - nullable: true, comment: "เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?", + default: false, }) positionIsSelected: boolean; @Column({ length: 40, comment: "เชื่อมโยงกับตารางเลขที่ตำแหน่ง", - default: "00000000-0000-0000-0000-000000000000", }) posMasterId: string; diff --git a/src/migration/1706758074991-update_table_guid_defult_null.ts b/src/migration/1706758074991-update_table_guid_defult_null.ts new file mode 100644 index 00000000..65d3a198 --- /dev/null +++ b/src/migration/1706758074991-update_table_guid_defult_null.ts @@ -0,0 +1,38 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableGuidDefultNull1706758074991 implements MigrationInterface { + name = 'UpdateTableGuidDefultNull1706758074991' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`ancestorDNA\` \`isAncestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้'`); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_e3827e0630023124de4e6a9063f\``); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posExecutiveId\` \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_dc2d0309e4642e0599f27b22271\``); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posExecutiveId\` \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_e3827e0630023124de4e6a9063f\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_dc2d0309e4642e0599f27b22271\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_dc2d0309e4642e0599f27b22271\``); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_e3827e0630023124de4e6a9063f\``); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posExecutiveId\` \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_dc2d0309e4642e0599f27b22271\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posExecutiveId\` \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_e3827e0630023124de4e6a9063f\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`isAncestorDNA\` \`isAncestorDNA\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`isAncestorDNA\` \`ancestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้' DEFAULT 'string'`); + } + +} diff --git a/src/migration/1706758236425-update_table_guid_defult_null1.ts b/src/migration/1706758236425-update_table_guid_defult_null1.ts new file mode 100644 index 00000000..8b431aa8 --- /dev/null +++ b/src/migration/1706758236425-update_table_guid_defult_null1.ts @@ -0,0 +1,144 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableGuidDefultNull11706758236425 implements MigrationInterface { + name = 'UpdateTableGuidDefultNull11706758236425' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_82aff1cb1e02d1640b5cb384420\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_3848be44d5d26ff438c893c662e\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_4bb600399098cb8596babcc9b12\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_36291e45193793ac8730d5b9ff4\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_cdefa5d1dc0141102324ed4bfc2\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild2Id\` \`orgChild2Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild3Id\` \`orgChild3Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_1f1f5214555b0e653c40924c453\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_85c7a51d4ba358817c2187ba0c0\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_abe35eefd8fb2bf682542c57b5e\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_897d37984d8749690da88b538a4\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild2Id\` \`orgChild2Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_298491a199687ab46c830db5675\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_b3e512809e7e8dea0a6a1c0d95f\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_7826c78069b4cdf5b5656460f90\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_9481ca31027bf02594ed533b765\``); + await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_4f53766362a9ee2b19969343513\``); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP FOREIGN KEY \`FK_b9d787230c285dcd0ba4c63d33b\``); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_f601e38caafa049c60b4eac6f06\``); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL`); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_9abc42b86d67e0f30ed64683936\``); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_f73c785c0db2d5178d63f3b6c46\``); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'ตำแหน่งประเภท'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posLevelId\` \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_663dce303cab0a73190d2b55a52\``); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_6dcc1bd887c6b4a660391ab2dc5\``); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_bfcf6ec9f1e08c2a351be8df46a\``); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'ประเภทตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posLevelId\` \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posMasterId\` \`posMasterId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`posLevel\` DROP FOREIGN KEY \`FK_66caa3d974b67a8a8b343d029b2\``); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'เป็นระดับของประเภทตำแหน่งใด'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_cdefa5d1dc0141102324ed4bfc2\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_82aff1cb1e02d1640b5cb384420\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_3848be44d5d26ff438c893c662e\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_4bb600399098cb8596babcc9b12\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_36291e45193793ac8730d5b9ff4\` FOREIGN KEY (\`orgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_897d37984d8749690da88b538a4\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_1f1f5214555b0e653c40924c453\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_85c7a51d4ba358817c2187ba0c0\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_abe35eefd8fb2bf682542c57b5e\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_7826c78069b4cdf5b5656460f90\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_298491a199687ab46c830db5675\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_b3e512809e7e8dea0a6a1c0d95f\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_4f53766362a9ee2b19969343513\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_9481ca31027bf02594ed533b765\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD CONSTRAINT \`FK_b9d787230c285dcd0ba4c63d33b\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_f601e38caafa049c60b4eac6f06\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_9abc42b86d67e0f30ed64683936\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_f73c785c0db2d5178d63f3b6c46\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_bfcf6ec9f1e08c2a351be8df46a\` FOREIGN KEY (\`posMasterId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_663dce303cab0a73190d2b55a52\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_6dcc1bd887c6b4a660391ab2dc5\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posLevel\` ADD CONSTRAINT \`FK_66caa3d974b67a8a8b343d029b2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posLevel\` DROP FOREIGN KEY \`FK_66caa3d974b67a8a8b343d029b2\``); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_6dcc1bd887c6b4a660391ab2dc5\``); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_663dce303cab0a73190d2b55a52\``); + await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_bfcf6ec9f1e08c2a351be8df46a\``); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_f73c785c0db2d5178d63f3b6c46\``); + await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_9abc42b86d67e0f30ed64683936\``); + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_f601e38caafa049c60b4eac6f06\``); + await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP FOREIGN KEY \`FK_b9d787230c285dcd0ba4c63d33b\``); + await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_9481ca31027bf02594ed533b765\``); + await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_4f53766362a9ee2b19969343513\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_b3e512809e7e8dea0a6a1c0d95f\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_298491a199687ab46c830db5675\``); + await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_7826c78069b4cdf5b5656460f90\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_abe35eefd8fb2bf682542c57b5e\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_85c7a51d4ba358817c2187ba0c0\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_1f1f5214555b0e653c40924c453\``); + await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_897d37984d8749690da88b538a4\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_36291e45193793ac8730d5b9ff4\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_4bb600399098cb8596babcc9b12\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_3848be44d5d26ff438c893c662e\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_82aff1cb1e02d1640b5cb384420\``); + await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_cdefa5d1dc0141102324ed4bfc2\``); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'เป็นระดับของประเภทตำแหน่งใด' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posLevel\` ADD CONSTRAINT \`FK_66caa3d974b67a8a8b343d029b2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posMasterId\` \`posMasterId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posLevelId\` \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'ประเภทตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_bfcf6ec9f1e08c2a351be8df46a\` FOREIGN KEY (\`posMasterId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_6dcc1bd887c6b4a660391ab2dc5\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_663dce303cab0a73190d2b55a52\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posLevelId\` \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'ตำแหน่งประเภท' DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_f73c785c0db2d5178d63f3b6c46\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_9abc42b86d67e0f30ed64683936\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_f601e38caafa049c60b4eac6f06\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD CONSTRAINT \`FK_b9d787230c285dcd0ba4c63d33b\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_4f53766362a9ee2b19969343513\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_9481ca31027bf02594ed533b765\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_7826c78069b4cdf5b5656460f90\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_b3e512809e7e8dea0a6a1c0d95f\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_298491a199687ab46c830db5675\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild2Id\` \`orgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_897d37984d8749690da88b538a4\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_abe35eefd8fb2bf682542c57b5e\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_85c7a51d4ba358817c2187ba0c0\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_1f1f5214555b0e653c40924c453\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgRevisionId\` \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild3Id\` \`orgChild3Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild2Id\` \`orgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild1Id\` \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgRootId\` \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_cdefa5d1dc0141102324ed4bfc2\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_36291e45193793ac8730d5b9ff4\` FOREIGN KEY (\`orgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_4bb600399098cb8596babcc9b12\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_3848be44d5d26ff438c893c662e\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_82aff1cb1e02d1640b5cb384420\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} diff --git a/src/migration/1706760094173-update_table_guid_defult_null2.ts b/src/migration/1706760094173-update_table_guid_defult_null2.ts new file mode 100644 index 00000000..3c75584c --- /dev/null +++ b/src/migration/1706760094173-update_table_guid_defult_null2.ts @@ -0,0 +1,82 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableGuidDefultNull21706760094173 implements MigrationInterface { + name = 'UpdateTableGuidDefultNull21706760094173' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4Name\` \`orgChild4Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4ShortName\` \`orgChild4ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4Code\` \`orgChild4Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3Name\` \`orgChild3Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3ShortName\` \`orgChild3ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3Code\` \`orgChild3Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2Name\` \`orgChild2Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2ShortName\` \`orgChild2ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2Code\` \`orgChild2Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1Name\` \`orgChild1Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1ShortName\` \`orgChild1ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1Code\` \`orgChild1Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootName\` \`orgRootName\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(16) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootCode\` \`orgRootCode\` varchar(8) NULL COMMENT 'รหัสหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootRank\` \`orgRootRank\` enum ('DEPARTMENT', 'OFFICE', 'DIVISION', 'SECTION') NULL COMMENT 'ระดับของหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionName\` \`orgRevisionName\` varchar(255) NULL`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionIsCurrent\` \`orgRevisionIsCurrent\` tinyint NOT NULL DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionIsDraft\` \`orgRevisionIsDraft\` tinyint NOT NULL DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`posMasterNoPrefix\` \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`posMasterNoSuffix\` \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`profileIdCurrentHolder\` \`profileIdCurrentHolder\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`profileIdNextHolder\` \`profileIdNextHolder\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictName\` \`posDictName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictField\` \`posDictField\` varchar(255) NULL COMMENT 'สายงาน'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictExecutiveField\` \`posDictExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictArea\` \`posDictArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา'`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`posExecutiveName\` \`posExecutiveName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionName\` \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionField\` \`positionField\` varchar(45) NULL COMMENT 'สายงาน'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionExecutiveField\` \`positionExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionArea\` \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionIsSelected\` \`positionIsSelected\` tinyint NOT NULL COMMENT 'เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`posTypeName\` \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)'`); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`posLevelName\` \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`posLevelName\` \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`posTypeName\` \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionIsSelected\` \`positionIsSelected\` tinyint NULL COMMENT 'เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionArea\` \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionExecutiveField\` \`positionExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionField\` \`positionField\` varchar(45) NULL COMMENT 'สายงาน' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`positionName\` \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`posExecutiveName\` \`posExecutiveName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางการบริหาร' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictArea\` \`posDictArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictExecutiveField\` \`posDictExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictField\` \`posDictField\` varchar(255) NULL COMMENT 'สายงาน' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`posDictName\` \`posDictName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`profileIdNextHolder\` \`profileIdNextHolder\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`profileIdCurrentHolder\` \`profileIdCurrentHolder\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`posMasterNoSuffix\` \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`posMasterNoPrefix\` \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionIsDraft\` \`orgRevisionIsDraft\` tinyint NULL DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionIsCurrent\` \`orgRevisionIsCurrent\` tinyint NULL DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`orgRevisionName\` \`orgRevisionName\` varchar(255) NOT NULL DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootRank\` \`orgRootRank\` enum ('DEPARTMENT', 'OFFICE', 'DIVISION', 'SECTION') NULL COMMENT 'ระดับของหน่วยงาน' DEFAULT 'DEPARTMENT'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootCode\` \`orgRootCode\` varchar(8) NULL COMMENT 'รหัสหน่วยงาน' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootShortName\` \`orgRootShortName\` varchar(16) NULL COMMENT 'ชื่อย่อหน่วยงาน' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`orgRootName\` \`orgRootName\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1Code\` \`orgChild1Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1ShortName\` \`orgChild1ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`orgChild1Name\` \`orgChild1Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2Code\` \`orgChild2Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2ShortName\` \`orgChild2ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`orgChild2Name\` \`orgChild2Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3Code\` \`orgChild3Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3ShortName\` \`orgChild3ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`orgChild3Name\` \`orgChild3Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4Code\` \`orgChild4Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4ShortName\` \`orgChild4ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string'`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`orgChild4Name\` \`orgChild4Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string'`); + } + +}