เพิ่มlink relation
This commit is contained in:
parent
a41e33c0d4
commit
d74c3140fa
16 changed files with 416 additions and 139 deletions
18
src/migration/1706684320055-add_table_posMaster.ts
Normal file
18
src/migration/1706684320055-add_table_posMaster.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTablePosMaster1706684320055 implements MigrationInterface {
|
||||
name = 'AddTablePosMaster1706684320055'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`posMaster\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)' DEFAULT 'string', \`posMasterNo\` varchar(16) NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข' DEFAULT 'string', \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.' DEFAULT 'string', \`posMasterCreatedAt\` datetime NULL COMMENT 'วัน-เวลาที่สร้าง', \`ancestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้' DEFAULT 'string', \`posMasterOrder\` int NULL COMMENT 'ลำดับที่แสดงผล', \`posMasterPriority\` int NULL COMMENT 'ลำดับความสำคัญ', \`posMasterLine\` enum ('MAIN', 'SUPPORT') NULL COMMENT 'สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง', \`orgRootId\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild1Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild2Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild3Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild4Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`profileIdCurrentHolder\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้' DEFAULT 'string', \`profileIdNextHolder\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย' DEFAULT 'string', \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`position\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string', \`positionField\` varchar(45) NULL COMMENT 'สายงาน' DEFAULT 'string', \`posTypeId\` varchar(40) NOT NULL COMMENT 'ประเภทตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000', \`positionExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string', \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string', \`positionIsSelected\` tinyint NULL COMMENT 'เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?', \`posMasterId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`posDict\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posDictName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string', \`posDictField\` varchar(255) NULL COMMENT 'สายงาน' DEFAULT 'string', \`posTypeId\` varchar(40) NOT NULL COMMENT 'ตำแหน่งประเภท' DEFAULT '00000000-0000-0000-0000-000000000000', \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000', \`posDictExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string', \`posDictArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE \`posDict\``);
|
||||
await queryRunner.query(`DROP TABLE \`position\``);
|
||||
await queryRunner.query(`DROP TABLE \`posMaster\``);
|
||||
}
|
||||
|
||||
}
|
||||
48
src/migration/1706685942091-add_table_posMaster1.ts
Normal file
48
src/migration/1706685942091-add_table_posMaster1.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTablePosMaster11706685942091 implements MigrationInterface {
|
||||
name = 'AddTablePosMaster11706685942091'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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 \`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 \`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 \`orgChild1\` ADD CONSTRAINT \`FK_4f53766362a9ee2b19969343513\` 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_e3827e0630023124de4e6a9063f\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`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_dc2d0309e4642e0599f27b22271\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`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`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
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_dc2d0309e4642e0599f27b22271\``);
|
||||
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 \`posDict\` DROP FOREIGN KEY \`FK_e3827e0630023124de4e6a9063f\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_f601e38caafa049c60b4eac6f06\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_4f53766362a9ee2b19969343513\``);
|
||||
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_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_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\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue