migrate
This commit is contained in:
parent
86f04ed0f9
commit
0701347040
4 changed files with 175 additions and 218 deletions
|
|
@ -1,210 +1,209 @@
|
||||||
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, OneToMany } from "typeorm";
|
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, OneToMany } from "typeorm"
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base"
|
||||||
import { Assign } from "./Assign";
|
import { Assign } from "./Assign"
|
||||||
import { Appoint } from "./Appoint";
|
import { Appoint } from "./Appoint"
|
||||||
import { Survey } from "./Survey";
|
import { Survey } from "./Survey"
|
||||||
|
|
||||||
@Entity("personal")
|
@Entity("personal")
|
||||||
export class Personal extends EntityBase {
|
export class Personal extends EntityBase {
|
||||||
@PrimaryGeneratedColumn("uuid")
|
@PrimaryGeneratedColumn("uuid")
|
||||||
personal_id: string;
|
personal_id: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "เลขที่คำสั่งบรรจุ",
|
comment: "เลขที่คำสั่งบรรจุ",
|
||||||
})
|
})
|
||||||
order_number!: string;
|
order_number!: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
comment:
|
comment:
|
||||||
"1 อยู่ระหว่างการทดลองปฏิบัติหน้าที่ราชการ, 2 พ้นการทดลองปฏิบัติหน้าที่ราชการ, 3 ไม่พ้นการทดลองปฏิบัติหน้าที่ราชการ, 4 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากเปลี่ยนตำแหน่ง, 5 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากลาออก, 6 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากถึงแก่กรรม, 7 ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการ, 8 ดึงรายชื่อไปออกคำสั่งแล้ว",
|
"1 อยู่ระหว่างการทดลองปฏิบัติหน้าที่ราชการ, 2 พ้นการทดลองปฏิบัติหน้าที่ราชการ, 3 ไม่พ้นการทดลองปฏิบัติหน้าที่ราชการ, 4 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากเปลี่ยนตำแหน่ง, 5 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากลาออก, 6 ยุติการทดลองปฏิบัติหน้าที่ราชการเนื่องจากถึงแก่กรรม, 7 ขยายระยะเวลาทดลองปฏิบัติหน้าที่ราชการ, 8 ดึงรายชื่อไปออกคำสั่งแล้ว",
|
||||||
default: 1,
|
default: 1,
|
||||||
})
|
})
|
||||||
probation_status: number;
|
probation_status: number
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
comment: "สถานะการใช้งาน 1 คือใช้งานปกติ, 0 คือไม่ใช้งาน",
|
comment: "สถานะการใช้งาน 1 คือใช้งานปกติ, 0 คือไม่ใช้งาน",
|
||||||
default: 1,
|
default: 1,
|
||||||
})
|
})
|
||||||
active: number;
|
active: number
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "คำนำหน้าชื่อ",
|
comment: "คำนำหน้าชื่อ",
|
||||||
})
|
})
|
||||||
prefixName: string;
|
prefixName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
comment: "ชื่อ",
|
comment: "ชื่อ",
|
||||||
})
|
})
|
||||||
firstName: string;
|
firstName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
comment: "นามสกุล",
|
comment: "นามสกุล",
|
||||||
})
|
})
|
||||||
lastName: string;
|
lastName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
comment: "สถานะการทดลองงาน 1 คืออยู่ระหว่างการทดลองงาน, 0 คือไม่อยู่ระหว่างการทดลองงาน",
|
comment: "สถานะการทดลองงาน 1 คืออยู่ระหว่างการทดลองงาน, 0 คือไม่อยู่ระหว่างการทดลองงาน",
|
||||||
default: 0,
|
default: 0,
|
||||||
})
|
})
|
||||||
isProbation: number;
|
isProbation: number
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ตำแหน่งในสายงาน",
|
comment: "ตำแหน่งในสายงาน",
|
||||||
})
|
})
|
||||||
positionName: string;
|
positionName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "เลขที่ตำแหน่ง",
|
comment: "เลขที่ตำแหน่ง",
|
||||||
})
|
})
|
||||||
posNo: string;
|
posNo: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ระดับตำแหน่ง",
|
comment: "ระดับตำแหน่ง",
|
||||||
})
|
})
|
||||||
positionLevelName: string;
|
positionLevelName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ด้าน/สาขา",
|
comment: "ด้าน/สาขา",
|
||||||
})
|
})
|
||||||
positionLineName: string;
|
positionLineName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ประเภทตำแหน่ง",
|
comment: "ประเภทตำแหน่ง",
|
||||||
})
|
})
|
||||||
positionTypeName: string;
|
positionTypeName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "หน่วยงาน",
|
comment: "หน่วยงาน",
|
||||||
})
|
})
|
||||||
orgRootName: string;
|
orgRootName: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "สังกัด",
|
comment: "สังกัด",
|
||||||
})
|
})
|
||||||
organization: string;
|
organization: string
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "เลขบัตรประจำตัวประชาชน",
|
comment: "เลขบัตรประจำตัวประชาชน",
|
||||||
})
|
})
|
||||||
idcard: string;
|
idcard: string
|
||||||
|
|
||||||
@Column({ nullable: true, comment: "id หน่วยงาน root", default: null })
|
@Column({ nullable: true, comment: "id หน่วยงาน root", default: null })
|
||||||
root: string;
|
root: string
|
||||||
|
|
||||||
@Column({ nullable: true, comment: "id หน่วยงาน child1", default: null })
|
@Column({ nullable: true, comment: "id หน่วยงาน child1", default: null })
|
||||||
child1: string;
|
child1: string
|
||||||
|
|
||||||
@Column({ nullable: true, comment: "id หน่วยงาน child2", default: null })
|
@Column({ nullable: true, comment: "id หน่วยงาน child2", default: null })
|
||||||
child2: string;
|
child2: string
|
||||||
|
|
||||||
@Column({ nullable: true, comment: "id หน่วยงาน child3", default: null })
|
@Column({ nullable: true, comment: "id หน่วยงาน child3", default: null })
|
||||||
child3: string;
|
child3: string
|
||||||
|
|
||||||
@Column({ nullable: true, comment: "id หน่วยงาน child4", default: null })
|
@Column({ nullable: true, comment: "id หน่วยงาน child4", default: null })
|
||||||
child4: string;
|
child4: string
|
||||||
|
|
||||||
@OneToMany(() => Assign, (assign: Assign) => assign.personal_id)
|
@OneToMany(() => Assign, (assign: Assign) => assign.personal_id)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
assign: Assign[];
|
assign: Assign[]
|
||||||
|
|
||||||
@OneToOne(() => Appoint, (appoint) => appoint.personal)
|
@OneToOne(() => Appoint, appoint => appoint.personal)
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
appoint: Appoint;
|
appoint: Appoint
|
||||||
|
|
||||||
@OneToOne(() => Survey, (survey) => survey.personal)
|
@OneToOne(() => Survey, { nullable: true })
|
||||||
@JoinColumn({ name: "personal_id" })
|
survey: Survey | null
|
||||||
survey: Survey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreatePersonal {
|
export class CreatePersonal {
|
||||||
@Column()
|
@Column()
|
||||||
personal_id: string;
|
personal_id: string
|
||||||
@Column()
|
@Column()
|
||||||
order_number: string;
|
order_number: string
|
||||||
@Column()
|
@Column()
|
||||||
probation_status: number;
|
probation_status: number
|
||||||
// @Column()
|
// @Column()
|
||||||
// profiles: PersonalProfile;
|
// profiles: PersonalProfile;
|
||||||
@Column()
|
@Column()
|
||||||
createdUserId: string;
|
createdUserId: string
|
||||||
@Column()
|
@Column()
|
||||||
createdFullName: string;
|
createdFullName: string
|
||||||
@Column()
|
@Column()
|
||||||
updateUserId: string;
|
updateUserId: string
|
||||||
@Column()
|
@Column()
|
||||||
updateFullName: string;
|
updateFullName: string
|
||||||
@Column()
|
@Column()
|
||||||
prefixName: string;
|
prefixName: string
|
||||||
@Column()
|
@Column()
|
||||||
firstName: string;
|
firstName: string
|
||||||
@Column()
|
@Column()
|
||||||
lastName: string;
|
lastName: string
|
||||||
@Column()
|
@Column()
|
||||||
isProbation: number;
|
isProbation: number
|
||||||
@Column()
|
@Column()
|
||||||
positionName: string;
|
positionName: string
|
||||||
@Column()
|
@Column()
|
||||||
posNo: string;
|
posNo: string
|
||||||
@Column()
|
@Column()
|
||||||
positionLevelName: string;
|
positionLevelName: string
|
||||||
@Column()
|
@Column()
|
||||||
positionTypeName: string;
|
positionTypeName: string
|
||||||
@Column()
|
@Column()
|
||||||
positionLineName: string;
|
positionLineName: string
|
||||||
@Column()
|
@Column()
|
||||||
orgRootName: string;
|
orgRootName: string
|
||||||
@Column()
|
@Column()
|
||||||
organization: string;
|
organization: string
|
||||||
@Column()
|
@Column()
|
||||||
idcard: string;
|
idcard: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PostPersonal {
|
export class PostPersonal {
|
||||||
id: string;
|
id: string
|
||||||
prefix: string;
|
prefix: string
|
||||||
firstName: string;
|
firstName: string
|
||||||
lastName: string;
|
lastName: string
|
||||||
isProbation: boolean;
|
isProbation: boolean
|
||||||
posTypeName?: string | null;
|
posTypeName?: string | null
|
||||||
posLevelName: string | null;
|
posLevelName: string | null
|
||||||
position: string | null;
|
position: string | null
|
||||||
posLineName?: string | null;
|
posLineName?: string | null
|
||||||
posNo?: string | null;
|
posNo?: string | null
|
||||||
organization?: string;
|
organization?: string
|
||||||
orgRootName: string | null;
|
orgRootName: string | null
|
||||||
orgChild1Name?: string | null;
|
orgChild1Name?: string | null
|
||||||
orgChild2Name?: string | null;
|
orgChild2Name?: string | null
|
||||||
orgChild3Name?: string | null;
|
orgChild3Name?: string | null
|
||||||
orgChild4Name?: string | null;
|
orgChild4Name?: string | null
|
||||||
|
|
||||||
order_number?: string;
|
order_number?: string
|
||||||
rank?: string | null;
|
rank?: string | null
|
||||||
idcard?: string;
|
idcard?: string
|
||||||
positionField?: string | null;
|
positionField?: string | null
|
||||||
positionArea?: string | null;
|
positionArea?: string | null
|
||||||
posExecutiveName?: string | null;
|
posExecutiveName?: string | null
|
||||||
positionExecutiveField?: string | null;
|
positionExecutiveField?: string | null
|
||||||
|
|
||||||
root?: string | null;
|
root?: string | null
|
||||||
child1?: string | null;
|
child1?: string | null
|
||||||
child2?: string | null;
|
child2?: string | null
|
||||||
child3?: string | null;
|
child3?: string | null
|
||||||
child4?: string | null;
|
child4?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdatePersonal = Partial<CreatePersonal>;
|
export type UpdatePersonal = Partial<CreatePersonal>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class Updated1736239463356 implements MigrationInterface {
|
|
||||||
name = 'Updated1736239463356'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`appoint\` DROP FOREIGN KEY \`FK_46c617b30fd9def96938f43b6ee\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` DROP FOREIGN KEY \`FK_5abc77b4bd19c4295cabe6a3bf5\``);
|
|
||||||
await queryRunner.query(`DROP INDEX \`REL_46c617b30fd9def96938f43b6e\` ON \`appoint\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` ADD \`appointId\` varchar(36) NULL`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` ADD UNIQUE INDEX \`IDX_5c42dcafb9ff2c3785b9bf447a\` (\`appointId\`)`);
|
|
||||||
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_5c42dcafb9ff2c3785b9bf447a\` ON \`personal\` (\`appointId\`)`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` ADD CONSTRAINT \`FK_5c42dcafb9ff2c3785b9bf447a3\` FOREIGN KEY (\`appointId\`) REFERENCES \`appoint\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` DROP FOREIGN KEY \`FK_5c42dcafb9ff2c3785b9bf447a3\``);
|
|
||||||
await queryRunner.query(`DROP INDEX \`REL_5c42dcafb9ff2c3785b9bf447a\` ON \`personal\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` DROP INDEX \`IDX_5c42dcafb9ff2c3785b9bf447a\``);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` DROP COLUMN \`appointId\``);
|
|
||||||
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_46c617b30fd9def96938f43b6e\` ON \`appoint\` (\`profileId\`)`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` ADD CONSTRAINT \`FK_5abc77b4bd19c4295cabe6a3bf5\` FOREIGN KEY (\`personal_id\`) REFERENCES \`appoint\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`appoint\` ADD CONSTRAINT \`FK_46c617b30fd9def96938f43b6ee\` FOREIGN KEY (\`profileId\`) REFERENCES \`personal\`(\`personal_id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateRelationSurvey1737442569342 implements MigrationInterface {
|
|
||||||
name = 'UpdateRelationSurvey1737442569342'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP INDEX \`IDX_5c42dcafb9ff2c3785b9bf447a\` ON \`personal\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_5c42dcafb9ff2c3785b9bf447a\` ON \`personal\` (\`appointId\`)`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
export class UpdateRelationSurvey1737443725676 implements MigrationInterface {
|
export class UpdateRelationSurvey1737456985846 implements MigrationInterface {
|
||||||
name = 'UpdateRelationSurvey1737443725676'
|
name = 'UpdateRelationSurvey1737456985846'
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` ADD CONSTRAINT \`FK_53ffbd1e99fe0da682dab5c77ff\` FOREIGN KEY (\`personal_id\`, \`personal_id\`) REFERENCES \`survey\`(\`personal_id\`,\`assign_id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`survey\` ADD CONSTRAINT \`FK_9bae89d4bb00502e057fb619a70\` FOREIGN KEY (\`personal_id\`) REFERENCES \`personal\`(\`personal_id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
await queryRunner.query(`ALTER TABLE \`survey\` ADD CONSTRAINT \`FK_9bae89d4bb00502e057fb619a70\` FOREIGN KEY (\`personal_id\`) REFERENCES \`personal\`(\`personal_id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE \`survey\` DROP FOREIGN KEY \`FK_9bae89d4bb00502e057fb619a70\``);
|
await queryRunner.query(`ALTER TABLE \`survey\` DROP FOREIGN KEY \`FK_9bae89d4bb00502e057fb619a70\``);
|
||||||
await queryRunner.query(`ALTER TABLE \`personal\` DROP FOREIGN KEY \`FK_53ffbd1e99fe0da682dab5c77ff\``);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue