diff --git a/src/entities/CommandSys.ts b/src/entities/CommandSys.ts index 0aee2270..7e50f3ae 100644 --- a/src/entities/CommandSys.ts +++ b/src/entities/CommandSys.ts @@ -77,8 +77,8 @@ export class CommandSys { @OneToMany(() => Assign, (assgin) => assgin.commandAssignSys) assgins: Assign[]; - @OneToMany(() => Workflow, (workflow) => workflow.commandSys) - workflows: Workflow[]; + // @OneToMany(() => Workflow, (workflow) => workflow.commandSys) + // workflows: Workflow[]; } export class CreateCommandSys { diff --git a/src/entities/PosLevel.ts b/src/entities/PosLevel.ts index 807ce0ec..7eb67e93 100644 --- a/src/entities/PosLevel.ts +++ b/src/entities/PosLevel.ts @@ -58,8 +58,8 @@ export class PosLevel extends EntityBase { @OneToMany(() => Profile, (profile) => profile.posLevel) profiles: Profile[]; - @OneToMany(() => Workflow, (workflow) => workflow.posLevel) - workflows: Workflow[]; +// @OneToMany(() => Workflow, (workflow) => workflow.posLevel) +// workflows: Workflow[]; } export class CreatePosLevel { diff --git a/src/entities/PosType.ts b/src/entities/PosType.ts index 6b5cc2b1..9abb9633 100644 --- a/src/entities/PosType.ts +++ b/src/entities/PosType.ts @@ -36,8 +36,8 @@ export class PosType extends EntityBase { @OneToMany(() => Profile, (profile) => profile.posType) profiles: Profile[]; - @OneToMany(() => Workflow, (workflow) => workflow.posType) - workflows: Workflow[]; + // @OneToMany(() => Workflow, (workflow) => workflow.posType) + // workflows: Workflow[]; } export class CreatePosType { diff --git a/src/entities/Workflow.ts b/src/entities/Workflow.ts index dd5d7b71..8b81b00d 100644 --- a/src/entities/Workflow.ts +++ b/src/entities/Workflow.ts @@ -23,66 +23,66 @@ export class Workflow extends EntityBase { }) category: string; - // @Column({ - // nullable: true, - // comment: "กรุ๊ปเลือด", - // length: 255, - // default: null, - // }) - // rank: string; - - // @Column({ - // nullable: true, - // comment: "กรุ๊ปเลือด", - // length: 255, - // default: null, - // }) - // executive: string; - - // @Column({ - // nullable: true, - // comment: "หมวดหมู่ระบบ", - // length: 255, - // default: null, - // }) - // system: string; - @OneToMany(() => State, (state) => state.workflow) states: State[]; - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง commandSys", - default: null, - }) - commandSysId: string; + // @Column({ + // nullable: true, + // length: 40, + // comment: "คีย์นอก(FK)ของตาราง commandSys", + // default: null, + // }) + // commandSysId: string; - @ManyToOne(() => CommandSys, (commandSys) => commandSys.workflows) - @JoinColumn({ name: "commandSysId" }) - commandSys: CommandSys; + // @ManyToOne(() => CommandSys, (commandSys) => commandSys.workflows) + // @JoinColumn({ name: "commandSysId" }) + // commandSys: CommandSys; + + // @Column({ + // nullable: true, + // length: 40, + // comment: "คีย์นอก(FK)ของตาราง posLevel", + // default: null, + // }) + // posLevelId: string; + + // @ManyToOne(() => PosLevel, (posLevel) => posLevel.workflows) + // @JoinColumn({ name: "posLevelId" }) + // posLevel: PosLevel; + + // @Column({ + // nullable: true, + // length: 40, + // comment: "คีย์นอก(FK)ของตาราง posType", + // default: null, + // }) + // posTypeId: string; + + // @ManyToOne(() => PosType, (posType) => posType.workflows) + // @JoinColumn({ name: "posTypeId" }) + // posType: PosType; @Column({ nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง posLevel", + comment: "ชื่อระบบ", + length: 100, default: null, }) - posLevelId: string; - - @ManyToOne(() => PosLevel, (posLevel) => posLevel.workflows) - @JoinColumn({ name: "posLevelId" }) - posLevel: PosLevel; + commandSysName: string; @Column({ nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง posType", + comment: "ชื่อระดับ", + length: 100, default: null, }) - posTypeId: string; + posLevelName: string; - @ManyToOne(() => PosType, (posType) => posType.workflows) - @JoinColumn({ name: "posTypeId" }) - posType: PosType; + @Column({ + nullable: true, + comment: "ชื่อประเภท", + length: 100, + default: null, + }) + posTypeName: string; } diff --git a/src/migration/1728442861469-add_table_workflow1.ts b/src/migration/1728442861469-add_table_workflow1.ts new file mode 100644 index 00000000..7b26d1e8 --- /dev/null +++ b/src/migration/1728442861469-add_table_workflow1.ts @@ -0,0 +1,30 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableWorkflow11728442861469 implements MigrationInterface { + name = 'AddTableWorkflow11728442861469' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`workflow\` DROP FOREIGN KEY \`FK_0eadcb967c5bdb18867395b8bf9\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP FOREIGN KEY \`FK_248dca7108cc3ba484d7eac2bc2\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP FOREIGN KEY \`FK_77889a7cde943b64fc28dd06025\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`commandSysId\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`posLevelId\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`posTypeId\``); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`commandSysName\` varchar(100) NULL COMMENT 'ชื่อระบบ'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`posLevelName\` varchar(100) NULL COMMENT 'ชื่อระดับ'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`posTypeName\` varchar(100) NULL COMMENT 'ชื่อประเภท'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`posTypeName\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`posLevelName\``); + await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`commandSysName\``); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`posTypeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง posType'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`posLevelId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง posLevel'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`commandSysId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง commandSys'`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD CONSTRAINT \`FK_77889a7cde943b64fc28dd06025\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD CONSTRAINT \`FK_248dca7108cc3ba484d7eac2bc2\` FOREIGN KEY (\`commandSysId\`) REFERENCES \`commandSys\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`workflow\` ADD CONSTRAINT \`FK_0eadcb967c5bdb18867395b8bf9\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +}