This commit is contained in:
Kittapath 2024-05-14 11:17:00 +07:00
parent a826726c80
commit d57d4220dd

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileemployeeAddPk41715660157678 implements MigrationInterface {
name = 'UpdateTableProfileemployeeAddPk41715660157678'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileChildren\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileChildren\` ADD CONSTRAINT \`FK_50655e719f668b71918a6f22e6d\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_6a37dfb48ea6108cba60b9d4f69\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_6a37dfb48ea6108cba60b9d4f69\``);
await queryRunner.query(`ALTER TABLE \`profileChildren\` DROP FOREIGN KEY \`FK_50655e719f668b71918a6f22e6d\``);
await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`profileChildren\` DROP COLUMN \`profileEmployeeId\``);
}
}