From 5d185ee60e2b65b10bec5a67b677724128f4f1e7 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 20 Feb 2025 14:04:54 +0700 Subject: [PATCH] migrate --- src/entities/EmployeePosition.ts | 4 ++-- ...ddtableorgtemp1.ts => 1740034804747-addtableorgtemp1.ts} | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename src/migration/{1740033601269-addtableorgtemp1.ts => 1740034804747-addtableorgtemp1.ts} (57%) diff --git a/src/entities/EmployeePosition.ts b/src/entities/EmployeePosition.ts index 8deaefcf..ab8aa9b7 100644 --- a/src/entities/EmployeePosition.ts +++ b/src/entities/EmployeePosition.ts @@ -49,11 +49,11 @@ export class EmployeePosition extends EntityBase { }) posMasterTempId: string; - @ManyToOne(() => EmployeePosMaster, (posMaster) => posMaster) + @ManyToOne(() => EmployeePosMaster, (posMaster) => posMaster.positions) @JoinColumn({ name: "posMasterId" }) posMaster: EmployeePosMaster; - @ManyToOne(() => EmployeeTempPosMaster, (posMaster) => posMaster) + @ManyToOne(() => EmployeeTempPosMaster, (posMaster) => posMaster.positions) @JoinColumn({ name: "posMasterTempId" }) posMasterTemp: EmployeeTempPosMaster; diff --git a/src/migration/1740033601269-addtableorgtemp1.ts b/src/migration/1740034804747-addtableorgtemp1.ts similarity index 57% rename from src/migration/1740033601269-addtableorgtemp1.ts rename to src/migration/1740034804747-addtableorgtemp1.ts index 79a1cc17..ade37805 100644 --- a/src/migration/1740033601269-addtableorgtemp1.ts +++ b/src/migration/1740034804747-addtableorgtemp1.ts @@ -1,14 +1,16 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class Addtableorgtemp11740033601269 implements MigrationInterface { - name = 'Addtableorgtemp11740033601269' +export class Addtableorgtemp11740034804747 implements MigrationInterface { + name = 'Addtableorgtemp11740034804747' public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD \`posMasterTempId\` varchar(40) NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง'`); await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD CONSTRAINT \`FK_d98cc02c1c2f9830afcb1493b00\` FOREIGN KEY (\`posMasterTempId\`) REFERENCES \`employeeTempPosMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP FOREIGN KEY \`FK_d98cc02c1c2f9830afcb1493b00\``); + await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP COLUMN \`posMasterTempId\``); } }