This commit is contained in:
Kittapath 2024-06-07 10:54:47 +07:00
parent a46c942e1c
commit a937794ba9

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileempAddGroup11717732414982 implements MigrationInterface {
name = 'UpdateTableProfileempAddGroup11717732414982'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`profileEmployeeInformationHistory\` (\`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', \`positionEmployeeGroupId\` varchar(255) NULL COMMENT 'กลุ่มงาน', \`positionEmployeeLineId\` varchar(255) NULL COMMENT 'สายงาน', \`positionEmployeePositionId\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งทางสายงาน', \`employeeOc\` varchar(255) NULL COMMENT 'สังกัด', \`employeeTypeIndividual\` varchar(255) NULL COMMENT 'ประเภทบุคคล', \`employeeWage\` varchar(255) NULL COMMENT 'ค่าจ้าง', \`employeeMoneyIncrease\` varchar(255) NULL COMMENT 'เงินเพิ่มการครองชีพชั่วคราว', \`employeeMoneyAllowance\` varchar(255) NULL COMMENT 'เงินช่วยเหลือการครองชีพชั่วคราว', \`employeeMoneyEmployee\` varchar(255) NULL COMMENT 'เงินสมทบประกันสังคม(ลูกจ้าง)', \`employeeMoneyEmployer\` varchar(255) NULL COMMENT 'เงินสมทบประกันสังคม(นายจ้าง)', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`profileEmployeeEmployment\` (\`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', \`date\` datetime NULL COMMENT 'วันที่จ้าง', \`command\` varchar(255) NULL COMMENT 'คำสั่งจ้าง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`profileEmployeeEmploymentHistory\` (\`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', \`date\` datetime NULL COMMENT 'วันที่จ้าง', \`command\` varchar(255) NULL COMMENT 'คำสั่งจ้าง', \`profileEmployeeEmploymentId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployeeEmployment', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` ADD CONSTRAINT \`FK_83fb1847aac8764cf663ba22deb\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` ADD CONSTRAINT \`FK_70701d021ef74fdd16fd72065e2\` FOREIGN KEY (\`profileEmployeeEmploymentId\`) REFERENCES \`profileEmployeeEmployment\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` DROP FOREIGN KEY \`FK_70701d021ef74fdd16fd72065e2\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` DROP FOREIGN KEY \`FK_83fb1847aac8764cf663ba22deb\``);
await queryRunner.query(`DROP TABLE \`profileEmployeeEmploymentHistory\``);
await queryRunner.query(`DROP TABLE \`profileEmployeeEmployment\``);
await queryRunner.query(`DROP TABLE \`profileEmployeeInformationHistory\``);
}
}