เพิ่มtableลูกจ้าง

This commit is contained in:
Kittapath 2024-03-15 14:32:08 +07:00
parent 912a8237e6
commit 21c044223c
11 changed files with 1490 additions and 15 deletions

View file

@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableProfileEmployee1710487869374 implements MigrationInterface {
name = 'AddTableProfileEmployee1710487869374'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_00221b20fdf6d460a86f108fc6d\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_41945621a3f1e716dc3b2d994c3\``);
await queryRunner.query(`CREATE TABLE \`profileEmployee\` (\`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', \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง', \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีกลุ่มงานตำแหน่ง', \`email\` varchar(255) NULL COMMENT 'อีเมล', \`phone\` varchar(20) NULL COMMENT 'เบอร์โทร', \`keycloak\` varchar(40) NULL COMMENT 'id keycloak', \`isProbation\` tinyint NOT NULL COMMENT 'ทดลองปฏิบัติหน้าที่' DEFAULT 0, \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ', \`birthDate\` datetime NULL COMMENT 'วันเกิด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_00221b20fdf6d460a86f108fc6d\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_41945621a3f1e716dc3b2d994c3\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD CONSTRAINT \`FK_cc1b55a08a76d0d3e254c37e11e\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD CONSTRAINT \`FK_773469f2924994e83e9835c48f9\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP FOREIGN KEY \`FK_773469f2924994e83e9835c48f9\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP FOREIGN KEY \`FK_cc1b55a08a76d0d3e254c37e11e\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_41945621a3f1e716dc3b2d994c3\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_00221b20fdf6d460a86f108fc6d\``);
await queryRunner.query(`DROP TABLE \`profileEmployee\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_41945621a3f1e716dc3b2d994c3\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_00221b20fdf6d460a86f108fc6d\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}