From 93c20a4c9669f11bf9e47cc5aaa477d183ce01b4 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:15:16 +0700 Subject: [PATCH 1/2] feat: add note to history --- src/entities/ProfileEducationHistory.ts | 21 ++++++++++++++------ src/entities/ProfileInsigniaHistory.ts | 26 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/entities/ProfileEducationHistory.ts b/src/entities/ProfileEducationHistory.ts index c1d6cc33..3454130c 100644 --- a/src/entities/ProfileEducationHistory.ts +++ b/src/entities/ProfileEducationHistory.ts @@ -5,7 +5,6 @@ import { ProfileEducation } from "./ProfileEducation"; @Entity("profileEducationHistory") export class ProfileEducationHistory extends EntityBase { - @Column({ comment: "สถานะการใช้งาน", default: false, @@ -108,7 +107,7 @@ export class ProfileEducationHistory extends EntityBase { @Column({ nullable: true, comment: "ระดับศึกษา", - type: "text", // ใช้ "text" แทน "string" เพื่อรองรับ long text + type: "text", // ใช้ "text" แทน "string" เพื่อรองรับ long text default: null, }) educationLevel: string; @@ -151,6 +150,13 @@ export class ProfileEducationHistory extends EntityBase { }) isEducation: boolean; + @Column({ + nullable: true, + comment: "หมายเหตุ", + default: null, + }) + note: string; + @Column({ nullable: true, length: 40, @@ -158,15 +164,16 @@ export class ProfileEducationHistory extends EntityBase { default: null, }) profileEducationId: string; - - @ManyToOne(() => ProfileEducation, (profileEducation) => profileEducation.profileEducationHistories) + + @ManyToOne( + () => ProfileEducation, + (profileEducation) => profileEducation.profileEducationHistories, + ) @JoinColumn({ name: "profileEducationId" }) histories: ProfileEducation; - } export class CreateProfileEducationHistory { - @Column() isActive: boolean; @@ -227,6 +234,8 @@ export class CreateProfileEducationHistory { @Column("uuid") profileEducationId: string | null; + @Column() + note: string | null; } export type UpdateProfileEducationHistory = Partial; diff --git a/src/entities/ProfileInsigniaHistory.ts b/src/entities/ProfileInsigniaHistory.ts index a03c4b83..7ca99f56 100644 --- a/src/entities/ProfileInsigniaHistory.ts +++ b/src/entities/ProfileInsigniaHistory.ts @@ -5,7 +5,6 @@ import { ProfileInsignia } from "./ProfileInsignia"; @Entity("profileInsigniaHistory") export class ProfileInsigniaHistory extends EntityBase { - @Column({ comment: "สถานะการใช้งาน", default: false, @@ -40,7 +39,7 @@ export class ProfileInsigniaHistory extends EntityBase { default: null, }) section: string; - + @Column({ nullable: true, length: 30, @@ -56,7 +55,7 @@ export class ProfileInsigniaHistory extends EntityBase { default: null, }) receiveDate: Date; - + @Column({ nullable: true, length: 40, @@ -64,7 +63,7 @@ export class ProfileInsigniaHistory extends EntityBase { default: null, }) insigniaId: string; - + @Column({ nullable: true, comment: "ประเภท", @@ -113,6 +112,13 @@ export class ProfileInsigniaHistory extends EntityBase { }) refCommandNo: string; + @Column({ + nullable: true, + comment: "หมายเหตุ", + default: null, + }) + note: string; + @Column({ nullable: true, length: 40, @@ -127,10 +133,9 @@ export class ProfileInsigniaHistory extends EntityBase { } export class CreateProfileInsigniaHistory { - @Column() isActive: boolean; - + @Column() year: number; @@ -142,16 +147,16 @@ export class CreateProfileInsigniaHistory { @Column() section: string | null; - + @Column() page: string | null; @Column() receiveDate: Date | null; - + @Column("uuid") insigniaId: string | null; - + @Column() insigniaType: string | null; @@ -170,6 +175,9 @@ export class CreateProfileInsigniaHistory { @Column() refCommandNo: string | null; + @Column() + note: string | null; + @Column("uuid") profileInsigniaId: string | null; } From 340289a670ac9e806a6420f52a162ce0fd6d4116 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:20:34 +0700 Subject: [PATCH 2/2] chore: add migration --- ...7773-update_table_profile_history_add_note.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/migration/1710749867773-update_table_profile_history_add_note.ts diff --git a/src/migration/1710749867773-update_table_profile_history_add_note.ts b/src/migration/1710749867773-update_table_profile_history_add_note.ts new file mode 100644 index 00000000..1d3cc342 --- /dev/null +++ b/src/migration/1710749867773-update_table_profile_history_add_note.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfileHistoryAddNote1710749867773 implements MigrationInterface { + name = 'UpdateTableProfileHistoryAddNote1710749867773' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` ADD \`note\` varchar(255) NULL COMMENT 'หมายเหตุ'`); + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` ADD \`note\` varchar(255) NULL COMMENT 'หมายเหตุ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` DROP COLUMN \`note\``); + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` DROP COLUMN \`note\``); + } + +}