migrate db

This commit is contained in:
Kittapath 2024-04-23 11:15:53 +07:00
parent 784ec51ac1
commit 44f669b5b1
3 changed files with 61 additions and 30 deletions

View file

@ -40,36 +40,6 @@ export class KpiCapacity extends EntityBase {
}) })
description: string; description: string;
@Column({
nullable: true,
comment: "ระดับที่คาดหวัง",
default: null,
})
level: string;
@Column({
nullable: true,
comment: "น้ำหนัก",
default: null,
})
weight: number;
@Column({
nullable: true,
comment: "ระดับคะแนน",
default: null,
})
point: number;
@Column({
type: "double",
nullable: true,
default: null,
comment: "ผลการประเมิน"
})
summary: number;
@OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacity) @OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacity)
kpiCapacityDetails: KpiCapacityDetail[]; kpiCapacityDetails: KpiCapacityDetail[];

View file

@ -5,6 +5,35 @@ import { KpiUserEvaluation } from "./kpiUserEvaluation";
@Entity("kpiUserCapacity") @Entity("kpiUserCapacity")
export class KpiUserCapacity extends EntityBase { export class KpiUserCapacity extends EntityBase {
@Column({
nullable: true,
comment: "ระดับที่คาดหวัง",
default: null,
})
level: string;
@Column({
nullable: true,
comment: "น้ำหนัก",
default: null,
})
weight: number;
@Column({
nullable: true,
comment: "ระดับคะแนน",
default: null,
})
point: number;
@Column({
type: "double",
nullable: true,
default: null,
comment: "ผลการประเมิน",
})
summary: number;
@Column({ @Column({
nullable: true, nullable: true,
length: 40, length: 40,

View file

@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableKpiuserroleAddSummary1713845708267 implements MigrationInterface {
name = 'UpdateTableKpiuserroleAddSummary1713845708267'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`point\` int NULL COMMENT 'ระดับคะแนน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`summary\` double NULL COMMENT 'ผลการประเมิน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`point\` int NULL COMMENT 'ระดับคะแนน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`summary\` double NULL COMMENT 'ผลการประเมิน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` ADD \`level\` varchar(255) NULL COMMENT 'ระดับที่คาดหวัง'`);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` ADD \`weight\` int NULL COMMENT 'น้ำหนัก'`);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` ADD \`point\` int NULL COMMENT 'ระดับคะแนน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` ADD \`summary\` double NULL COMMENT 'ผลการประเมิน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล ดังนี้ PENDING = รอดำเนินการ, INPROGRESS = กําลังดำเนินการ, DONE = ประเมินเสร็จสิ้น'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationResults\` \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationResults\` \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationStatus\` \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล'`);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` DROP COLUMN \`summary\``);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` DROP COLUMN \`point\``);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` DROP COLUMN \`weight\``);
await queryRunner.query(`ALTER TABLE \`kpiUserCapacity\` DROP COLUMN \`level\``);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`summary\``);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`point\``);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`summary\``);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`point\``);
}
}