migrate responsibility
This commit is contained in:
parent
6311c9cb0d
commit
2eee5404a1
11 changed files with 285 additions and 37 deletions
59
src/controllers/ProfileAvatarController.ts
Normal file
59
src/controllers/ProfileAvatarController.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { Body, Controller, Delete, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||||
|
import { AppDataSource } from "../database/data-source";
|
||||||
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
import HttpError from "../interfaces/http-error";
|
||||||
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
|
import { Profile } from "../entities/Profile";
|
||||||
|
import { CreateProfileAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||||
|
|
||||||
|
@Route("api/v1/org/profile/avatar")
|
||||||
|
@Tags("ProfileAvatar")
|
||||||
|
@Security("bearerAuth")
|
||||||
|
export class ProfileAvatarController extends Controller {
|
||||||
|
private profileRepository = AppDataSource.getRepository(Profile);
|
||||||
|
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
||||||
|
|
||||||
|
@Get("{profileId}")
|
||||||
|
public async getAvatar(@Path() profileId: string) {
|
||||||
|
const lists = await this.avatarRepository.find({
|
||||||
|
where: { profileId: profileId },
|
||||||
|
});
|
||||||
|
return new HttpSuccess(lists);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) {
|
||||||
|
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new ProfileAvatar();
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
createdUserId: req.user.sub,
|
||||||
|
createdFullName: req.user.name,
|
||||||
|
lastUpdateUserId: req.user.sub,
|
||||||
|
lastUpdateFullName: req.user.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
||||||
|
await this.avatarRepository.save(data);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete("{avatarId}")
|
||||||
|
public async deleteAvatar(@Path() avatarId: string) {
|
||||||
|
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||||
|
|
||||||
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/controllers/ProfileAvatarEmployeeController.ts
Normal file
62
src/controllers/ProfileAvatarEmployeeController.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { Body, Controller, Delete, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||||
|
import { AppDataSource } from "../database/data-source";
|
||||||
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
import HttpError from "../interfaces/http-error";
|
||||||
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
|
import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
|
||||||
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
|
||||||
|
@Route("api/v1/org/profile-employee/avatar")
|
||||||
|
@Tags("ProfileAvatar")
|
||||||
|
@Security("bearerAuth")
|
||||||
|
export class ProfileAvatarController extends Controller {
|
||||||
|
private profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||||
|
private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
|
||||||
|
|
||||||
|
@Get("{profileId}")
|
||||||
|
public async getAvatar(@Path() profileId: string) {
|
||||||
|
const lists = await this.avatarRepository.find({
|
||||||
|
where: { profileEmployeeId: profileId },
|
||||||
|
});
|
||||||
|
return new HttpSuccess(lists);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
public async newAvatar(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Body() body: CreateProfileEmployeeAvatar,
|
||||||
|
) {
|
||||||
|
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
|
||||||
|
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new ProfileAvatar();
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
createdUserId: req.user.sub,
|
||||||
|
createdFullName: req.user.name,
|
||||||
|
lastUpdateUserId: req.user.sub,
|
||||||
|
lastUpdateFullName: req.user.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(data, { ...body, ...meta });
|
||||||
|
|
||||||
|
await this.avatarRepository.save(data);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete("{avatarId}")
|
||||||
|
public async deleteAvatar(@Path() avatarId: string) {
|
||||||
|
const result = await this.avatarRepository.delete({ id: avatarId });
|
||||||
|
|
||||||
|
if (result.affected == undefined || result.affected <= 0) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -108,14 +108,13 @@ export class OrgChild1 extends EntityBase {
|
||||||
})
|
})
|
||||||
ancestorDNA: string;
|
ancestorDNA: string;
|
||||||
|
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
length: 255,
|
length: 255,
|
||||||
comment: "หน้าที่ความรับผิดชอบ",
|
comment: "หน้าที่ความรับผิดชอบ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duty: string;
|
responsibility: string;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
|
@ -165,10 +164,9 @@ export class CreateOrgChild1 {
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
orgRootId: string;
|
orgRootId: string;
|
||||||
|
|
||||||
@Column()
|
|
||||||
duty?: string;
|
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
responsibility?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateOrgChild1 = Partial<CreateOrgChild1> & { orgChild1Rank?: OrgChild1Rank };
|
export type UpdateOrgChild1 = Partial<CreateOrgChild1> & { orgChild1Rank?: OrgChild1Rank };
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ export class OrgChild2 extends EntityBase {
|
||||||
comment: "หน้าที่ความรับผิดชอบ",
|
comment: "หน้าที่ความรับผิดชอบ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duty: string;
|
responsibility: string;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild2s)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild2s)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
|
@ -172,7 +172,6 @@ export class CreateOrgChild2 {
|
||||||
orgChild1Id: string;
|
orgChild1Id: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
duty?: string;
|
responsibility?: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
export type UpdateOrgChild2 = Partial<CreateOrgChild2> & { orgChild2Rank?: OrgChild2Rank };
|
export type UpdateOrgChild2 = Partial<CreateOrgChild2> & { orgChild2Rank?: OrgChild2Rank };
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ export class OrgChild3 extends EntityBase {
|
||||||
comment: "หน้าที่ความรับผิดชอบ",
|
comment: "หน้าที่ความรับผิดชอบ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duty: string;
|
responsibility: string;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild3s)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild3s)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
|
@ -180,7 +180,7 @@ export class CreateOrgChild3 {
|
||||||
orgChild2Id: string;
|
orgChild2Id: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
duty?: string;
|
responsibility?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateOrgChild3 = Partial<CreateOrgChild3> & { orgChild3Rank?: OrgChild3Rank };
|
export type UpdateOrgChild3 = Partial<CreateOrgChild3> & { orgChild3Rank?: OrgChild3Rank };
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ export class OrgChild4 extends EntityBase {
|
||||||
comment: "หน้าที่ความรับผิดชอบ",
|
comment: "หน้าที่ความรับผิดชอบ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duty: string;
|
responsibility: string;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild4s)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild4s)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
|
@ -186,6 +186,6 @@ export class CreateOrgChild4 {
|
||||||
orgChild3Id: string;
|
orgChild3Id: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
duty?: string;
|
responsibility?: string;
|
||||||
}
|
}
|
||||||
export type UpdateOrgChild4 = Partial<OrgChild4>;
|
export type UpdateOrgChild4 = Partial<OrgChild4>;
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ export class OrgRoot extends EntityBase {
|
||||||
comment: "หน้าที่ความรับผิดชอบ",
|
comment: "หน้าที่ความรับผิดชอบ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duty: string;
|
responsibility: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
length: 40,
|
length: 40,
|
||||||
|
|
@ -156,7 +156,7 @@ export class CreateOrgRoot {
|
||||||
orgRootFax?: string;
|
orgRootFax?: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
duty?: string;
|
responsibility?: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
orgRevisionId: string;
|
orgRevisionId: string;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,17 @@ import { ProfileGovernment } from "./ProfileGovernment";
|
||||||
import { Province } from "./Province";
|
import { Province } from "./Province";
|
||||||
import { SubDistrict } from "./SubDistrict";
|
import { SubDistrict } from "./SubDistrict";
|
||||||
import { District } from "./District";
|
import { District } from "./District";
|
||||||
|
import { ProfileAvatar } from "./ProfileAvatar";
|
||||||
|
|
||||||
@Entity("profile")
|
@Entity("profile")
|
||||||
export class Profile extends EntityBase {
|
export class Profile extends EntityBase {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "รูปถ่าย",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
avatar: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ยศ",
|
comment: "ยศ",
|
||||||
|
|
@ -294,6 +302,9 @@ export class Profile extends EntityBase {
|
||||||
@OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
|
@OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
|
||||||
profileOthers: ProfileOther[];
|
profileOthers: ProfileOther[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProfileAvatar, (profileAvatar) => profileAvatar.profile)
|
||||||
|
profileAvatars: ProfileAvatar[];
|
||||||
|
|
||||||
@OneToMany(() => ProfileFamilyHistory, (profileFamily) => profileFamily.profile)
|
@OneToMany(() => ProfileFamilyHistory, (profileFamily) => profileFamily.profile)
|
||||||
profileFamily: ProfileFamilyHistory[];
|
profileFamily: ProfileFamilyHistory[];
|
||||||
|
|
||||||
|
|
@ -576,35 +587,35 @@ export class CreateProfileAllFields {
|
||||||
posLevelId: string | null;
|
posLevelId: string | null;
|
||||||
posTypeId: string | null;
|
posTypeId: string | null;
|
||||||
email: string | null;
|
email: string | null;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
keycloak: string | null;
|
keycloak: string | null;
|
||||||
isProbation: boolean | null;
|
isProbation: boolean | null;
|
||||||
isLeave : boolean | null;
|
isLeave: boolean | null;
|
||||||
dateRetire : Date | null;
|
dateRetire: Date | null;
|
||||||
dateAppoint : Date | null;
|
dateAppoint: Date | null;
|
||||||
dateStart: Date | null;
|
dateStart: Date | null;
|
||||||
govAgeAbsent: number | null;
|
govAgeAbsent: number | null;
|
||||||
govAgePlus: number | null;
|
govAgePlus: number | null;
|
||||||
birthDate: Date | null;
|
birthDate: Date | null;
|
||||||
reasonSameDate : Date | null;
|
reasonSameDate: Date | null;
|
||||||
ethnicity : string | null;
|
ethnicity: string | null;
|
||||||
telephoneNumber : string | null;
|
telephoneNumber: string | null;
|
||||||
nationality : string | null;
|
nationality: string | null;
|
||||||
gender : string | null;
|
gender: string | null;
|
||||||
relationship : string | null;
|
relationship: string | null;
|
||||||
religion : string | null;
|
religion: string | null;
|
||||||
bloodGroup : string | null;
|
bloodGroup: string | null;
|
||||||
registrationAddress : string | null;
|
registrationAddress: string | null;
|
||||||
registrationProvinceId : string | null;
|
registrationProvinceId: string | null;
|
||||||
registrationDistrictId: string | null;
|
registrationDistrictId: string | null;
|
||||||
registrationSubDistrictId : string | null;
|
registrationSubDistrictId: string | null;
|
||||||
registrationZipCode : string | null;
|
registrationZipCode: string | null;
|
||||||
currentAddress : string | null;
|
currentAddress: string | null;
|
||||||
currentProvinceId : string | null;
|
currentProvinceId: string | null;
|
||||||
currentDistrictId : string | null;
|
currentDistrictId: string | null;
|
||||||
currentSubDistrictId : string | null;
|
currentSubDistrictId: string | null;
|
||||||
currentZipCode : string | null;
|
currentZipCode: string | null;
|
||||||
};
|
}
|
||||||
|
|
||||||
export type UpdateProfile = {
|
export type UpdateProfile = {
|
||||||
rank?: string | null;
|
rank?: string | null;
|
||||||
|
|
|
||||||
52
src/entities/ProfileAvatar.ts
Normal file
52
src/entities/ProfileAvatar.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { Profile } from "./Profile";
|
||||||
|
import { ProfileEmployee } from "./ProfileEmployee";
|
||||||
|
|
||||||
|
@Entity("profileAvatar")
|
||||||
|
export class ProfileAvatar extends EntityBase {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "รูปถ่าย",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
avatar: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง Profile",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileEmployeeId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Profile, (profile) => profile.profileAvatars)
|
||||||
|
@JoinColumn({ name: "profileId" })
|
||||||
|
profile: Profile;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileAvatars)
|
||||||
|
@JoinColumn({ name: "profileEmployeeId" })
|
||||||
|
profileEmployee: ProfileEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateProfileAvatar {
|
||||||
|
profileId: string;
|
||||||
|
avatar: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateProfileEmployeeAvatar {
|
||||||
|
profileEmployeeId: string;
|
||||||
|
avatar: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UpdateProfileAvatar = {
|
||||||
|
avatar?: string | null;
|
||||||
|
};
|
||||||
|
|
@ -19,8 +19,16 @@ import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily";
|
||||||
import { ProfileEducation } from "./ProfileEducation";
|
import { ProfileEducation } from "./ProfileEducation";
|
||||||
import { ProfileAbility } from "./ProfileAbility";
|
import { ProfileAbility } from "./ProfileAbility";
|
||||||
import { ProfileOther } from "./ProfileOther";
|
import { ProfileOther } from "./ProfileOther";
|
||||||
|
import { ProfileAvatar } from "./ProfileAvatar";
|
||||||
@Entity("profileEmployee")
|
@Entity("profileEmployee")
|
||||||
export class ProfileEmployee extends EntityBase {
|
export class ProfileEmployee extends EntityBase {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "รูปถ่าย",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
avatar: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)",
|
comment: "ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)",
|
||||||
|
|
@ -255,6 +263,9 @@ export class ProfileEmployee extends EntityBase {
|
||||||
@OneToMany(() => ProfileOther, (v) => v.profileEmployee)
|
@OneToMany(() => ProfileOther, (v) => v.profileEmployee)
|
||||||
profileOthers: ProfileOther[];
|
profileOthers: ProfileOther[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProfileAvatar, (v) => v.profileEmployee)
|
||||||
|
profileAvatars: ProfileAvatar[];
|
||||||
|
|
||||||
@ManyToOne(() => EmployeePosLevel, (v) => v.profiles)
|
@ManyToOne(() => EmployeePosLevel, (v) => v.profiles)
|
||||||
posLevel: EmployeePosLevel;
|
posLevel: EmployeePosLevel;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableNodeAddResponsibility1715675159227 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableNodeAddResponsibility1715675159227'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`duty\` \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`duty\` \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`duty\` \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`duty\` \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`duty\` \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`CREATE TABLE \`profileAvatar\` (\`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) ON UPDATE 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 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`avatar\` varchar(255) NULL COMMENT 'รูปถ่าย', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`avatar\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`avatar\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`avatar\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`avatar\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD CONSTRAINT \`FK_e0db5c1a2f1facf02f03fbf78ea\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD CONSTRAINT \`FK_fb52fa49388a6e73b41ba8259a3\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP FOREIGN KEY \`FK_fb52fa49388a6e73b41ba8259a3\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP FOREIGN KEY \`FK_e0db5c1a2f1facf02f03fbf78ea\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP COLUMN \`responsibility\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD \`responsibility\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`avatar\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`avatar\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`avatar\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`avatar\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`profileAvatar\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`responsibility\` \`duty\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`responsibility\` \`duty\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`responsibility\` \`duty\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`responsibility\` \`duty\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`responsibility\` \`duty\` varchar(255) NULL COMMENT 'หน้าที่ความรับผิดชอบ'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue