แก้ db workflow

This commit is contained in:
kittapath 2024-10-09 10:05:39 +07:00
parent 7e6fdcb15e
commit 87b6fdf0d2
5 changed files with 83 additions and 53 deletions

View file

@ -77,8 +77,8 @@ export class CommandSys {
@OneToMany(() => Assign, (assgin) => assgin.commandAssignSys) @OneToMany(() => Assign, (assgin) => assgin.commandAssignSys)
assgins: Assign[]; assgins: Assign[];
@OneToMany(() => Workflow, (workflow) => workflow.commandSys) // @OneToMany(() => Workflow, (workflow) => workflow.commandSys)
workflows: Workflow[]; // workflows: Workflow[];
} }
export class CreateCommandSys { export class CreateCommandSys {

View file

@ -58,8 +58,8 @@ export class PosLevel extends EntityBase {
@OneToMany(() => Profile, (profile) => profile.posLevel) @OneToMany(() => Profile, (profile) => profile.posLevel)
profiles: Profile[]; profiles: Profile[];
@OneToMany(() => Workflow, (workflow) => workflow.posLevel) // @OneToMany(() => Workflow, (workflow) => workflow.posLevel)
workflows: Workflow[]; // workflows: Workflow[];
} }
export class CreatePosLevel { export class CreatePosLevel {

View file

@ -36,8 +36,8 @@ export class PosType extends EntityBase {
@OneToMany(() => Profile, (profile) => profile.posType) @OneToMany(() => Profile, (profile) => profile.posType)
profiles: Profile[]; profiles: Profile[];
@OneToMany(() => Workflow, (workflow) => workflow.posType) // @OneToMany(() => Workflow, (workflow) => workflow.posType)
workflows: Workflow[]; // workflows: Workflow[];
} }
export class CreatePosType { export class CreatePosType {

View file

@ -23,66 +23,66 @@ export class Workflow extends EntityBase {
}) })
category: string; 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) @OneToMany(() => State, (state) => state.workflow)
states: State[]; states: State[];
@Column({ // @Column({
nullable: true, // nullable: true,
length: 40, // length: 40,
comment: "คีย์นอก(FK)ของตาราง commandSys", // comment: "คีย์นอก(FK)ของตาราง commandSys",
default: null, // default: null,
}) // })
commandSysId: string; // commandSysId: string;
@ManyToOne(() => CommandSys, (commandSys) => commandSys.workflows) // @ManyToOne(() => CommandSys, (commandSys) => commandSys.workflows)
@JoinColumn({ name: "commandSysId" }) // @JoinColumn({ name: "commandSysId" })
commandSys: CommandSys; // 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({ @Column({
nullable: true, nullable: true,
length: 40, comment: "ชื่อระบบ",
comment: "คีย์นอก(FK)ของตาราง posLevel", length: 100,
default: null, default: null,
}) })
posLevelId: string; commandSysName: string;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.workflows)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@Column({ @Column({
nullable: true, nullable: true,
length: 40, comment: "ชื่อระดับ",
comment: "คีย์นอก(FK)ของตาราง posType", length: 100,
default: null, default: null,
}) })
posTypeId: string; posLevelName: string;
@ManyToOne(() => PosType, (posType) => posType.workflows) @Column({
@JoinColumn({ name: "posTypeId" }) nullable: true,
posType: PosType; comment: "ชื่อประเภท",
length: 100,
default: null,
})
posTypeName: string;
} }

View file

@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableWorkflow11728442861469 implements MigrationInterface {
name = 'AddTableWorkflow11728442861469'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`);
}
}