From b510ae62aaede24ac9e40e8fe5542c5d97859444 Mon Sep 17 00:00:00 2001 From: AnandaTon Date: Thu, 16 May 2024 09:35:11 +0700 Subject: [PATCH 1/4] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=82?= =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/ProfileDiscipline.ts | 1 + src/entities/ProfileSalaryEmployee.ts | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/entities/ProfileDiscipline.ts b/src/entities/ProfileDiscipline.ts index ca698a75..c9fb0f3c 100644 --- a/src/entities/ProfileDiscipline.ts +++ b/src/entities/ProfileDiscipline.ts @@ -15,6 +15,7 @@ export class ProfileDiscipline extends EntityBase { date: Date; @Column({ + nullable: true, length: 40, comment: "ไอดีโปรไฟล์", type: "uuid", diff --git a/src/entities/ProfileSalaryEmployee.ts b/src/entities/ProfileSalaryEmployee.ts index 6c6783e0..7b21dc74 100644 --- a/src/entities/ProfileSalaryEmployee.ts +++ b/src/entities/ProfileSalaryEmployee.ts @@ -222,11 +222,11 @@ export class ProfileSalaryEmployee extends EntityBase { }) order: number; - @Column({ - comment: "เลขที่คำสั่ง", - type: "text", - }) - commandNo: string; + // @Column({ + // comment: "เลขที่คำสั่ง", + // type: "text", + // }) + // commandNo: string; @Column({ comment: "ประเภทคำสั่ง", From 9d240969a35b37d6dc965f678dd934ff60684b89 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 09:37:43 +0700 Subject: [PATCH 2/4] migrate --- .../1715826963808-add_table_avatarName2.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/migration/1715826963808-add_table_avatarName2.ts diff --git a/src/migration/1715826963808-add_table_avatarName2.ts b/src/migration/1715826963808-add_table_avatarName2.ts new file mode 100644 index 00000000..837348e0 --- /dev/null +++ b/src/migration/1715826963808-add_table_avatarName2.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableAvatarName21715826963808 implements MigrationInterface { + name = 'AddTableAvatarName21715826963808' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` ADD \`commandNo\` text NOT NULL COMMENT 'เลขที่คำสั่ง'`); + } + +} From 73c91bd9b14bbd9933a96292b4e2e743acfb3899 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 10:01:59 +0700 Subject: [PATCH 3/4] update_table_ProfileAvatar_add_isactive --- src/controllers/ProfileAvatarController.ts | 2 ++ src/entities/ProfileAvatar.ts | 6 +++++ ...update_table_ProfileAvatar_add_isactive.ts | 22 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 85b9d70e..4b35f7b6 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -32,6 +32,7 @@ export class ProfileAvatarController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } + result.isActive = true; profile.avatar = result.avatar; profile.avatarName = result.avatarName; return new HttpSuccess(); @@ -59,6 +60,7 @@ export class ProfileAvatarController extends Controller { await this.avatarRepository.save(data); let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`; let fileName = `profile-${data.id}`; + data.isActive = true; data.avatar = avatar; data.avatarName = fileName; await this.avatarRepository.save(data); diff --git a/src/entities/ProfileAvatar.ts b/src/entities/ProfileAvatar.ts index 45364479..068ea56c 100644 --- a/src/entities/ProfileAvatar.ts +++ b/src/entities/ProfileAvatar.ts @@ -12,6 +12,12 @@ export class ProfileAvatar extends EntityBase { }) avatar: string; + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + @Column({ nullable: true, comment: "รูปถ่าย", diff --git a/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts b/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts new file mode 100644 index 00000000..fe4a419a --- /dev/null +++ b/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableProfileAvatarAddIsactive1715828430262 implements MigrationInterface { + name = 'UpdateTableProfileAvatarAddIsactive1715828430262' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์'`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP COLUMN \`isActive\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` ADD \`commandNo\` text NOT NULL COMMENT 'เลขที่คำสั่ง'`); + } + +} From 9317c3348b6799f4640d771e8cd0efa515f043d1 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 16 May 2024 10:04:41 +0700 Subject: [PATCH 4/4] no message --- ...62-update_table_ProfileAvatar_add_isactive.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts b/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts index fe4a419a..5bfd485a 100644 --- a/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts +++ b/src/migration/1715828430262-update_table_ProfileAvatar_add_isactive.ts @@ -4,19 +4,19 @@ export class UpdateTableProfileAvatarAddIsactive1715828430262 implements Migrati name = 'UpdateTableProfileAvatarAddIsactive1715828430262' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` DROP COLUMN \`commandNo\``); + // await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` DROP COLUMN \`commandNo\``); await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์'`); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์'`); + // await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` ADD \`commandNo\` text NOT NULL COMMENT 'เลขที่คำสั่ง'`); + // await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` ADD \`commandNo\` text NOT NULL COMMENT 'เลขที่คำสั่ง'`); } }