hrms-api-org/src/migration/1718350999556-update_table_posmaster_add_role5.ts
2024-06-14 15:14:16 +07:00

20 lines
1.5 KiB
TypeScript

import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTablePosmasterAddRole51718350999556 implements MigrationInterface {
name = 'UpdateTablePosmasterAddRole51718350999556'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD \`authRoleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD \`authRoleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง authRole'`);
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(`ALTER TABLE \`posMaster\` DROP COLUMN \`authRoleId\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP COLUMN \`authRoleId\``);
}
}