diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 474470de..828a2fc1 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -5594,6 +5594,7 @@ export class CommandController extends Controller { date: item.commandDateAffect, refCommandDate: item.commandDateSign, refCommandNo: `${item.commandNo}/${item.commandYear}`, + refCommandId: item.commandId, createdUserId: req.user.sub, createdFullName: req.user.name, lastUpdateUserId: req.user.sub, @@ -6117,6 +6118,7 @@ export class CommandController extends Controller { date: item.commandDateAffect, refCommandDate: item.commandDateSign, refCommandNo: `${item.commandNo}/${item.commandYear}`, + refCommandId: item.commandId, profileEmployeeId: item.profileId, profileId: undefined, }); diff --git a/src/entities/ProfileDiscipline.ts b/src/entities/ProfileDiscipline.ts index 0065528b..7a5f463d 100644 --- a/src/entities/ProfileDiscipline.ts +++ b/src/entities/ProfileDiscipline.ts @@ -61,6 +61,14 @@ export class ProfileDiscipline extends EntityBase { default: null, }) refCommandNo: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง command", + default: null, + }) + refCommandId: string; @Column({ nullable: true, diff --git a/src/entities/ProfileDisciplineHistory.ts b/src/entities/ProfileDisciplineHistory.ts index e7dfee58..d99a7263 100644 --- a/src/entities/ProfileDisciplineHistory.ts +++ b/src/entities/ProfileDisciplineHistory.ts @@ -51,6 +51,14 @@ export class ProfileDisciplineHistory extends EntityBase { }) refCommandNo: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง command", + default: null, + }) + refCommandId: string; + @Column({ nullable: true, comment: "ล้างมลทิน", diff --git a/src/migration/1780634210221-update_profileDiscipline_add_refCommandId.ts b/src/migration/1780634210221-update_profileDiscipline_add_refCommandId.ts new file mode 100644 index 00000000..9e5d1851 --- /dev/null +++ b/src/migration/1780634210221-update_profileDiscipline_add_refCommandId.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileDisciplineAddRefCommandId1780634210221 implements MigrationInterface { + name = 'UpdateProfileDisciplineAddRefCommandId1780634210221' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` ADD \`refCommandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD \`refCommandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP COLUMN \`refCommandId\``); + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` DROP COLUMN \`refCommandId\``); + } +}