migrate create table commandOperator #2220

This commit is contained in:
harid 2026-02-02 18:33:30 +07:00
parent e5e407e122
commit ec04da5611
3 changed files with 118 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import { CommandType } from "./CommandType";
import { CommandSend } from "./CommandSend";
import { CommandSalary } from "./CommandSalary";
import { CommandRecive } from "./CommandRecive";
import { CommandOperator } from "./CommandOperator";
import { ProfileSalary } from "./ProfileSalary";
import { ProfileSalaryHistory } from "./ProfileSalaryHistory";
import { CommandSign } from "./CommandSign";
@ -165,6 +166,9 @@ export class Command extends EntityBase {
@OneToMany(() => CommandRecive, (commandRecive) => commandRecive.command)
commandRecives: CommandRecive[];
@OneToMany(() => CommandOperator, (commandOperator) => commandOperator.command)
commandOperators: CommandOperator[];
@OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.command)
profileSalarys: ProfileSalary[];

View file

@ -0,0 +1,97 @@
import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { Command } from "./Command";
@Entity("commandOperator")
export class CommandOperator extends EntityBase {
@Column({
nullable: true,
comment: "คีย์นอก(FK)ของตาราง profile",
length: 40,
default: null,
})
profileId: string;
@Column({
nullable: true,
comment: "คำนำหน้า",
length: 255,
default: null,
})
prefix: string;
@Column({
nullable: true,
comment: "ชื่อ",
length: 255,
default: null,
})
firstName: string;
@Column({
nullable: true,
comment: "สกุล",
length: 255,
default: null,
})
lastName: string;
@Column({
nullable: true,
comment: "เลขที่ตำแหน่ง",
length: 255,
default: null,
})
posNo: string;
@Column({
nullable: true,
comment: "ประเภท",
length: 255,
default: null,
})
posType: string;
@Column({
nullable: true,
comment: "ระดับ",
length: 255,
default: null,
})
posLevel: string;
@Column({
nullable: true,
comment: "ตำแหน่งในสายงาน",
length: 255,
default: null,
})
position: string;
@Column({
nullable: true,
comment: "ตำแหน่งทางการบริหาร",
length: 255,
default: null,
})
positionExecutive: string;
@Column({
nullable: true,
comment: "บทบาทของเจ้าหน้าที่ดำเนินการ เช่น ผอ.สกจ. / รักษาการ ผอ.สกจ. / ผอ. กบห. / รักษาการ ผอ. กบห. / ผอ. ส่วน",
length: 255,
default: null,
})
roleName: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง command",
})
commandId: string;
@ManyToOne(() => Command, (command) => command.commandOperators)
@JoinColumn({ name: "commandId" })
command: Command;
}

View file

@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class CreateTableCommandOperator1770023808315 implements MigrationInterface {
name = 'CreateTableCommandOperator1770023808315'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`commandOperator\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'System Administrator', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'System Administrator', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`posNo\` varchar(255) NULL COMMENT 'เลขที่ตำแหน่ง', \`posType\` varchar(255) NULL COMMENT 'ประเภท', \`posLevel\` varchar(255) NULL COMMENT 'ระดับ', \`position\` varchar(255) NULL COMMENT 'ตำแหน่งในสายงาน', \`positionExecutive\` varchar(255) NULL COMMENT 'ตำแหน่งทางการบริหาร', \`roleName\` varchar(255) NULL COMMENT 'บทบาทของเจ้าหน้าที่ดำเนินการ เช่น ผอ.สกจ. / รักษาการ ผอ.สกจ. / ผอ. กบห. / รักษาการ ผอ. กบห. / ผอ. ส่วน', \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`commandOperator\` ADD CONSTRAINT \`FK_343a2ecd7cb855397f19a990008\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`commandOperator\` DROP FOREIGN KEY \`FK_343a2ecd7cb855397f19a990008\``);
await queryRunner.query(`DROP TABLE \`commandOperator\``);
}
}