migrate (ตัด relation ฟิลด์ posType, posLevel, empPosType, empPosLevel)

This commit is contained in:
Bright 2025-04-11 10:58:34 +07:00
parent 60781ea254
commit dbfc678e92
6 changed files with 255 additions and 178 deletions

View file

@ -370,44 +370,44 @@ export class DevelopmentController extends Controller {
await Promise.all( await Promise.all(
requestBody.positions.map(async (x) => { requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x); const _data = Object.assign(new PlannedGoalPosition(), x);
if (x.posTypePlannedId != null) { // if (x.posTypePlannedId != null) {
let checkId:any // let checkId:any
if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
checkId = await this.empPosTypeRepository.findOne({ // checkId = await this.empPosTypeRepository.findOne({
where: { id: x.posTypePlannedId }, // where: { id: x.posTypePlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
} // }
} // }
else { // else {
checkId = await this.posTypeRepository.findOne({ // checkId = await this.posTypeRepository.findOne({
where: { id: x.posTypePlannedId }, // where: { id: x.posTypePlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} // }
} // }
} // }
if (x.posLevelPlannedId != null) { // if (x.posLevelPlannedId != null) {
let checkId:any // let checkId:any
if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
checkId = await this.empPosLevelRepository.findOne({ // checkId = await this.empPosLevelRepository.findOne({
where: { id: x.posLevelPlannedId }, // where: { id: x.posLevelPlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
} // }
} // }
else { // else {
checkId = await this.posLevelRepository.findOne({ // checkId = await this.posLevelRepository.findOne({
where: { id: x.posLevelPlannedId }, // where: { id: x.posLevelPlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} // }
} // }
} // }
const before = structuredClone(development); const before = structuredClone(development);
_data.createdUserId = request.user.sub; _data.createdUserId = request.user.sub;
_data.createdFullName = request.user.name; _data.createdFullName = request.user.name;
@ -492,32 +492,32 @@ export class DevelopmentController extends Controller {
if (!development) { if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
} }
if (requestBody.posTypeActualId != null) { // if (requestBody.posTypeActualId != null) {
// addLogSequence(request, { // // addLogSequence(request, {
// action: "database", // // action: "database",
// status: "success", // // status: "success",
// description: "Get Position Type.", // // description: "Get Position Type.",
// }); // // });
const checkId = await this.posTypeRepository.findOne({ // const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeActualId }, // where: { id: requestBody.posTypeActualId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} // }
} // }
if (requestBody.posLevelActualId != null) { // if (requestBody.posLevelActualId != null) {
// addLogSequence(request, { // // addLogSequence(request, {
// action: "database", // // action: "database",
// status: "success", // // status: "success",
// description: "Get Position Level.", // // description: "Get Position Level.",
// }); // // });
const checkId = await this.posLevelRepository.findOne({ // const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelActualId }, // where: { id: requestBody.posLevelActualId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} // }
} // }
const before = structuredClone(development); const before = structuredClone(development);
const data = Object.assign(new ActualGoal(), requestBody); const data = Object.assign(new ActualGoal(), requestBody);
data.createdUserId = request.user.sub; data.createdUserId = request.user.sub;
@ -633,44 +633,44 @@ export class DevelopmentController extends Controller {
await Promise.all( await Promise.all(
requestBody.positions.map(async (x) => { requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x); const _data = Object.assign(new PlannedGoalPosition(), x);
if (x.posTypePlannedId != null) { // if (x.posTypePlannedId != null) {
let checkId:any // let checkId:any
if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { // if(requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
checkId = await this.empPosTypeRepository.findOne({ // checkId = await this.empPosTypeRepository.findOne({
where: { id: x.posTypePlannedId }, // where: { id: x.posTypePlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
} // }
} // }
else { // else {
checkId = await this.posTypeRepository.findOne({ // checkId = await this.posTypeRepository.findOne({
where: { id: x.posTypePlannedId }, // where: { id: x.posTypePlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} // }
} // }
} // }
if (x.posLevelPlannedId != null) { // if (x.posLevelPlannedId != null) {
let checkId:any // let checkId:any
if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) { // if (requestBody.groupTarget == "PERSONNEL" && (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
checkId = await this.empPosLevelRepository.findOne({ // checkId = await this.empPosLevelRepository.findOne({
where: { id: x.posLevelPlannedId }, // where: { id: x.posLevelPlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
} // }
} // }
else { // else {
checkId = await this.posLevelRepository.findOne({ // checkId = await this.posLevelRepository.findOne({
where: { id: x.posLevelPlannedId }, // where: { id: x.posLevelPlannedId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} // }
} // }
} // }
_data.createdUserId = request.user.sub; _data.createdUserId = request.user.sub;
_data.createdFullName = request.user.name; _data.createdFullName = request.user.name;
_data.lastUpdateUserId = request.user.sub; _data.lastUpdateUserId = request.user.sub;
@ -759,32 +759,32 @@ export class DevelopmentController extends Controller {
if (!development) { if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
} }
if (requestBody.posTypeActualId != null) { // if (requestBody.posTypeActualId != null) {
// addLogSequence(request, { // // addLogSequence(request, {
// action: "database", // // action: "database",
// status: "success", // // status: "success",
// description: "Get Position Type.", // // description: "Get Position Type.",
// }); // // });
const checkId = await this.posTypeRepository.findOne({ // const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeActualId }, // where: { id: requestBody.posTypeActualId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} // }
} // }
if (requestBody.posLevelActualId != null) { // if (requestBody.posLevelActualId != null) {
// addLogSequence(request, { // // addLogSequence(request, {
// action: "database", // // action: "database",
// status: "success", // // status: "success",
// description: "Get Position Level.", // // description: "Get Position Level.",
// }); // // });
const checkId = await this.posLevelRepository.findOne({ // const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelActualId }, // where: { id: requestBody.posLevelActualId },
}); // });
if (!checkId) { // if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} // }
} // }
const before = structuredClone(development); const before = structuredClone(development);
Object.assign(development, requestBody); Object.assign(development, requestBody);
development.lastUpdateUserId = request.user.sub; development.lastUpdateUserId = request.user.sub;
@ -2164,17 +2164,18 @@ export class DevelopmentController extends Controller {
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT");
const getDevelopment = await this.developmentRepository.findOne({ const getDevelopment = await this.developmentRepository.findOne({
where: { id: id }, where: { id: id },
//posTypeActual
relations: [ relations: [
"developmentActualPeoples", "developmentActualPeoples",
"developmentPlannedPeoples", "developmentPlannedPeoples",
"developmentActualGoals", "developmentActualGoals",
"developmentActualGoals.posTypeActual", // "developmentActualGoals.posTypeActual",
"developmentActualGoals.posLevelActual", // "developmentActualGoals.posLevelActual",
"developmentActualGoals", "developmentActualGoals",
"developmentPlannedGoals", "developmentPlannedGoals",
"developmentPlannedGoals.plannedGoalPositions", "developmentPlannedGoals.plannedGoalPositions",
"developmentPlannedGoals.plannedGoalPositions.posTypePlanned", // "developmentPlannedGoals.plannedGoalPositions.posTypePlanned",
"developmentPlannedGoals.plannedGoalPositions.posLevelPlanned", // "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned",
], ],
}); });
if (!getDevelopment) { if (!getDevelopment) {
@ -2212,10 +2213,12 @@ export class DevelopmentController extends Controller {
groupTarget: x.groupTarget, groupTarget: x.groupTarget,
groupTargetSub: x.groupTargetSub, groupTargetSub: x.groupTargetSub,
position: x.position, position: x.position,
posTypeId: x.posTypeActualId, // posTypeId: x.posTypeActualId,
posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName, // posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName,
posLevelId: x.posLevelActualId, // posLevelId: x.posLevelActualId,
posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName, // posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName,
posType: x.posTypeActual,
posLevel: x.posLevelActual,
type: x.type, type: x.type,
amount: x.amount, amount: x.amount,
})), })),
@ -2237,10 +2240,12 @@ export class DevelopmentController extends Controller {
id: y.id, id: y.id,
position: y.position, position: y.position,
posExecutive: y.posExecutive, posExecutive: y.posExecutive,
posTypeId: y.posTypePlannedId, // posTypeId: y.posTypePlannedId,
posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, // posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName,
posLevelId: y.posLevelPlannedId, // posLevelId: y.posLevelPlannedId,
posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName, // posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName,
posType: y.posTypePlanned,
posLevel: y.posLevelPlanned,
})), })),
amount: x.amount, amount: x.amount,
})), })),

View file

@ -29,25 +29,39 @@ export class ActualGoal extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "ประเภทตำแหน่ง", comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null, default: null,
}) })
posTypeActualId: string; posTypeActual: string;
// @Column({
// nullable: true,
// comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypeActualId: string;
@ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals) // @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals)
@JoinColumn({ name: "posTypeActualId" }) // @JoinColumn({ name: "posTypeActualId" })
posTypeActual: PosType; // posTypeActual: PosType;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับตำแหน่ง", comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null, default: null,
}) })
posLevelActualId: string; posLevelActual: string;
@ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals) // @Column({
@JoinColumn({ name: "posLevelActualId" }) // nullable: true,
posLevelActual: PosLevel; // comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelActualId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals)
// @JoinColumn({ name: "posLevelActualId" })
// posLevelActual: PosLevel;
@Column({ @Column({
nullable: true, nullable: true,
@ -82,10 +96,14 @@ export class CreateActualGoal {
groupTargetSub: string | null; groupTargetSub: string | null;
@Column() @Column()
position: string | null; position: string | null;
// @Column()
// posTypeActualId: string | null;
// @Column()
// posLevelActualId: string | null;
@Column() @Column()
posTypeActualId: string | null; posTypeActual: string | null;
@Column() @Column()
posLevelActualId: string | null; posLevelActual: string | null;
@Column() @Column()
type: string | null; type: string | null;
@Column() @Column()

View file

@ -22,25 +22,39 @@ export class PlannedGoalPosition extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "ประเภทตำแหน่ง", comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null, default: null,
}) })
posTypePlannedId: string; posTypePlanned: string;
@ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions) // @Column({
@JoinColumn({ name: "posTypePlannedId" }) // nullable: true,
posTypePlanned: PosType; // comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypePlannedId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions)
// @JoinColumn({ name: "posTypePlannedId" })
// posTypePlanned: PosType;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับตำแหน่ง", comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null, default: null,
}) })
posLevelPlannedId: string; posLevelPlanned: string;
@ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions) // @Column({
@JoinColumn({ name: "posLevelPlannedId" }) // nullable: true,
posLevelPlanned: PosLevel; // comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelPlannedId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions)
// @JoinColumn({ name: "posLevelPlannedId" })
// posLevelPlanned: PosLevel;
@Column({ @Column({
nullable: true, nullable: true,
@ -59,10 +73,14 @@ export class CreatePlannedGoalPosition {
position: string | null; position: string | null;
@Column() @Column()
posExecutive: string | null; posExecutive: string | null;
// @Column()
// posTypePlannedId: string | null;
// @Column()
// posLevelPlannedId: string | null;
@Column() @Column()
posTypePlannedId: string | null; posTypePlanned: string | null;
@Column() @Column()
posLevelPlannedId: string | null; posLevelPlanned: string | null;
} }
export type UpdatePlannedGoalPosition = Partial<CreatePlannedGoalPosition>; export type UpdatePlannedGoalPosition = Partial<CreatePlannedGoalPosition>;

View file

@ -48,14 +48,14 @@ export class PosLevel extends EntityBase {
@JoinColumn({ name: "posTypeId" }) @JoinColumn({ name: "posTypeId" })
posType: PosType; posType: PosType;
@OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual)
actualGoals: ActualGoal[]; // actualGoals: ActualGoal[];
@OneToMany( // @OneToMany(
() => PlannedGoalPosition, // () => PlannedGoalPosition,
(plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned, // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned,
) // )
plannedGoalPositions: PlannedGoalPosition[]; // plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel) @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel)
developmentHistorys: DevelopmentHistory[]; developmentHistorys: DevelopmentHistory[];

View file

@ -28,14 +28,14 @@ export class PosType extends EntityBase {
@OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType) @OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType)
posLevels: PosLevel[]; posLevels: PosLevel[];
@OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual) // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual)
actualGoals: ActualGoal[]; // actualGoals: ActualGoal[];
@OneToMany( // @OneToMany(
() => PlannedGoalPosition, // () => PlannedGoalPosition,
(plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned, // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned,
) // )
plannedGoalPositions: PlannedGoalPosition[]; // plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType) @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType)
developmentHistorys: DevelopmentHistory[]; developmentHistorys: DevelopmentHistory[];

View file

@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableActualGoalAndPlannedGoalPosition1744342850196 implements MigrationInterface {
name = 'UpdateTableActualGoalAndPlannedGoalPosition1744342850196'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_a9a864dd06eaa25edba8be8f24c\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_e08e337e5ddeb4942c72393ff58\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActualId\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActualId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlannedId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlannedId\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActual\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActual\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlanned\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlanned\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlanned\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlanned\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActual\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActual\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_8e7e0bf6eebd99f58e9b47c6b05\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_e08e337e5ddeb4942c72393ff58\` FOREIGN KEY (\`posTypeActualId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_a9a864dd06eaa25edba8be8f24c\` FOREIGN KEY (\`posLevelActualId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}