fix migration

This commit is contained in:
AdisakKanthawilang 2024-06-14 10:38:22 +07:00
parent 4bd16513de
commit 152d813bb4

View file

@ -1,28 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTablePosmasterAddRole11718266321698 implements MigrationInterface {
name = 'UpdateTablePosmasterAddRole11718266321698'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`authRoleId\` \`authRoleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD UNIQUE INDEX \`IDX_388ecc9f2a9f5b5ff1e08fd6d0\` (\`authRoleId\`)`);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`authRoleId\` \`authRoleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD UNIQUE INDEX \`IDX_a059796d095e79ba5b20407859\` (\`authRoleId\`)`);
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_388ecc9f2a9f5b5ff1e08fd6d0\` ON \`employeePosMaster\` (\`authRoleId\`)`);
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_a059796d095e79ba5b20407859\` ON \`posMaster\` (\`authRoleId\`)`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_388ecc9f2a9f5b5ff1e08fd6d0e\` FOREIGN KEY (\`authRoleId\`) REFERENCES \`authRole\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_a059796d095e79ba5b20407859f\` FOREIGN KEY (\`authRoleId\`) REFERENCES \`authRole\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_a059796d095e79ba5b20407859f\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_388ecc9f2a9f5b5ff1e08fd6d0e\``);
await queryRunner.query(`DROP INDEX \`REL_a059796d095e79ba5b20407859\` ON \`posMaster\``);
await queryRunner.query(`DROP INDEX \`REL_388ecc9f2a9f5b5ff1e08fd6d0\` ON \`employeePosMaster\``);
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP INDEX \`IDX_a059796d095e79ba5b20407859\``);
await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`authRoleId\` \`authRoleId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP INDEX \`IDX_388ecc9f2a9f5b5ff1e08fd6d0\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`authRoleId\` \`authRoleId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
}
}