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\``); } }