From f22cddbeeea15799dd63feea84b771dee665a503 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 8 May 2024 10:22:51 +0700 Subject: [PATCH] migrate --- src/entities/kpiSpecial.ts | 35 ++++++++++++------- src/entities/kpiUserSpecial.ts | 23 ++++++++++++ ...8-update_table_kpiPlan_add_achievement2.ts | 28 +++++++++++++++ 3 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 src/migration/1715138466608-update_table_kpiPlan_add_achievement2.ts diff --git a/src/entities/kpiSpecial.ts b/src/entities/kpiSpecial.ts index f1c2ba1..e6ae4db 100644 --- a/src/entities/kpiSpecial.ts +++ b/src/entities/kpiSpecial.ts @@ -61,6 +61,29 @@ export class KpiSpecial extends EntityBase { }) summary: number; + @Column({ + nullable: true, + comment: "ข้อมูลเอกสารหลักฐาน", + default: null, + }) + documentInfoEvidence: string; + + @Column({ + nullable: true, + type: "datetime", + comment: "ช่วงเวลาเริ่มเก็บข้อมูล", + default: null, + }) + startDate: Date; + + @Column({ + nullable: true, + type: "datetime", + comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", + default: null, + }) + endDate: Date; + @Column({ nullable: true, comment: "ผลสำเร็จของงาน 1", @@ -109,18 +132,6 @@ export class KpiSpecial extends EntityBase { default: null, }) formula: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", - default: null, - }) - kpiUserEvaluationId: string; - - @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserSpecials) - @JoinColumn({ name: "kpiUserEvaluationId" }) - kpiUserEvaluation: KpiUserEvaluation; } export class CreateKpiUserSpecial { diff --git a/src/entities/kpiUserSpecial.ts b/src/entities/kpiUserSpecial.ts index db46ae1..9bf8c41 100644 --- a/src/entities/kpiUserSpecial.ts +++ b/src/entities/kpiUserSpecial.ts @@ -61,6 +61,29 @@ export class KpiUserSpecial extends EntityBase { }) summary: number; + @Column({ + nullable: true, + comment: "ข้อมูลเอกสารหลักฐาน", + default: null, + }) + documentInfoEvidence: string; + + @Column({ + nullable: true, + type: "datetime", + comment: "ช่วงเวลาเริ่มเก็บข้อมูล", + default: null, + }) + startDate: Date; + + @Column({ + nullable: true, + type: "datetime", + comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", + default: null, + }) + endDate: Date; + @Column({ nullable: true, comment: "ผลสำเร็จของงาน 1", diff --git a/src/migration/1715138466608-update_table_kpiPlan_add_achievement2.ts b/src/migration/1715138466608-update_table_kpiPlan_add_achievement2.ts new file mode 100644 index 0000000..6d2bbe1 --- /dev/null +++ b/src/migration/1715138466608-update_table_kpiPlan_add_achievement2.ts @@ -0,0 +1,28 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableKpiPlanAddAchievement21715138466608 implements MigrationInterface { + name = 'UpdateTableKpiPlanAddAchievement21715138466608' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP FOREIGN KEY \`FK_10065ab86a67156f5dc6731f79e\``); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP COLUMN \`kpiUserEvaluationId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`documentInfoEvidence\` varchar(255) NULL COMMENT 'ข้อมูลเอกสารหลักฐาน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`startDate\` datetime NULL COMMENT 'ช่วงเวลาเริ่มเก็บข้อมูล'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`endDate\` datetime NULL COMMENT 'ช่วงเวลาสิ้นสุดเก็บข้อมูล'`); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD \`documentInfoEvidence\` varchar(255) NULL COMMENT 'ข้อมูลเอกสารหลักฐาน'`); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD \`startDate\` datetime NULL COMMENT 'ช่วงเวลาเริ่มเก็บข้อมูล'`); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD \`endDate\` datetime NULL COMMENT 'ช่วงเวลาสิ้นสุดเก็บข้อมูล'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP COLUMN \`endDate\``); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP COLUMN \`startDate\``); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP COLUMN \`documentInfoEvidence\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`endDate\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`startDate\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`documentInfoEvidence\``); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD \`kpiUserEvaluationId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง kpiUserEvaluation'`); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD CONSTRAINT \`FK_10065ab86a67156f5dc6731f79e\` FOREIGN KEY (\`kpiUserEvaluationId\`) REFERENCES \`kpiUserEvaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +}