From 5ca457e856fd9b0fd2b4bc989bd1b4747995c0d8 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 10:38:05 +0700 Subject: [PATCH] migrate --- src/entities/AnnounceTemplate.ts | 22 +++++++++++++++++++ src/entities/Evaluation.ts | 6 +++++ ...nceTemplate_and_update_field_evaluation.ts | 18 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/entities/AnnounceTemplate.ts create mode 100644 src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts diff --git a/src/entities/AnnounceTemplate.ts b/src/entities/AnnounceTemplate.ts new file mode 100644 index 0000000..6ff004f --- /dev/null +++ b/src/entities/AnnounceTemplate.ts @@ -0,0 +1,22 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Evaluation } from "./Evaluation"; + +@Entity("announcetemplate") +export class AnnounceTemplate extends EntityBase { + + @Column({ nullable: true, comment: "code สำหรับเรียก template" }) //ตัวอย่าง ST05-1 (ใช้ที่ STEP 5 ลำดับที่ 1) + code: string; + + @Column({ nullable: true, comment: "ชื่อประกาศ" }) + name: string; + + @Column({ type: 'text', nullable: true, comment: 'รายละเอียด'}) + detailBody: string; + + @Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย'}) + detailFooter: string; + +} + +export type UpdateAnnounceTemplate = Partial; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 657c46f..88eb5b4 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -266,6 +266,12 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS evaluationResult: string; + @Column({ type: 'text', nullable: true, comment: 'รายละเอียดประกาศ(STEP5)'}) + detailAnnounceStep5Body: string; + + @Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย(STEP5)'}) + detailAnnounceStep5Footer: string; + @OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation) evaluationLogs: EvaluationLogs[]; diff --git a/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts b/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts new file mode 100644 index 0000000..b975c38 --- /dev/null +++ b/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344 implements MigrationInterface { + name = 'CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`announcetemplate\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`code\` varchar(255) NULL COMMENT 'code สำหรับเรียก template', \`name\` varchar(255) NULL COMMENT 'ชื่อประกาศ', \`detailBody\` text NULL COMMENT 'รายละเอียด', \`detailFooter\` text NULL COMMENT 'รายละเอียดส่วนท้าย', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Body\` text NULL COMMENT 'รายละเอียดประกาศ(STEP5)'`); + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Footer\` text NULL COMMENT 'รายละเอียดส่วนท้าย(STEP5)'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Footer\``); + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Body\``); + await queryRunner.query(`DROP TABLE \`announcetemplate\``); + } + +}