migrate dna

This commit is contained in:
Moss 2025-06-16 21:34:15 +07:00
parent e16390b787
commit d51357e715
9 changed files with 243 additions and 183 deletions

View file

@ -370,20 +370,22 @@ export class DevelopmentController extends Controller {
await Promise.all(
requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x);
let checkPosType:any = null
let posTypeShortName:any = null
let checkPosType: any = null;
let posTypeShortName: any = null;
if (x.posTypePlanned) {
if(requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName
}
else {
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
@ -393,24 +395,28 @@ export class DevelopmentController extends Controller {
}
}
if (x.posLevelPlanned) {
let checkPosLevel:any
if (requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id
where: {
posTypeId: checkPosType.id,
},
});
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
}
else {
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
where: {
posLevelName: x.posLevelPlanned,
posTypeId: checkPosType.id
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
@ -502,20 +508,21 @@ export class DevelopmentController extends Controller {
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
}
let checkPosType:any = null
let posTypeShortName:any = null
let checkPosType: any = null;
let posTypeShortName: any = null;
if (requestBody.posTypeActual) {
if(requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName
}
else {
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
@ -525,24 +532,27 @@ export class DevelopmentController extends Controller {
}
}
if (requestBody.posLevelActual) {
let checkPosLevel:any
if (requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id
where: {
posTypeId: checkPosType.id,
},
});
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
}
else {
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
where: {
posLevelName: requestBody.posLevelActual,
posTypeId: checkPosType.id
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
@ -665,20 +675,22 @@ export class DevelopmentController extends Controller {
await Promise.all(
requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x);
let checkPosType:any = null
let posTypeShortName:any = null
let checkPosType: any = null;
let posTypeShortName: any = null;
if (x.posTypePlanned) {
if(requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName
}
else {
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
@ -688,24 +700,28 @@ export class DevelopmentController extends Controller {
}
}
if (x.posLevelPlanned) {
let checkPosLevel:any
if (requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id
where: {
posTypeId: checkPosType.id,
},
});
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
}
else {
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
where: {
posLevelName: x.posLevelPlanned,
posTypeId: checkPosType.id
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
@ -801,20 +817,21 @@ export class DevelopmentController extends Controller {
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
}
let checkPosType:any = null
let posTypeShortName:any = null
let checkPosType: any = null;
let posTypeShortName: any = null;
if (requestBody.posTypeActual) {
if(requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName
}
else {
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
@ -824,24 +841,27 @@ export class DevelopmentController extends Controller {
}
}
if (requestBody.posLevelActual) {
let checkPosLevel:any
if (requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id
where: {
posTypeId: checkPosType.id,
},
});
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
}
else {
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
where: {
posLevelName: requestBody.posLevelActual,
posTypeId: checkPosType.id
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
@ -2046,7 +2066,13 @@ export class DevelopmentController extends Controller {
@Query("node") node?: number | null,
@Query("keyword") keyword?: string,
) {
// await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP");
let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT");
await new CallAPI()
.PostData(request, "/org/finddna", _data)
.then((x) => {
_data = x;
})
.catch((x) => {});
const [development, total] = await AppDataSource.getRepository(Development)
.createQueryBuilder("development")
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
@ -2086,6 +2112,56 @@ export class DevelopmentController extends Controller {
keyword: `%${keyword}%`,
},
)
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `development.rootDnaId IN (:...root)`
: `development.rootDnaId is null`
: "1=1",
{
root: _data.root,
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `development.child1DnaId IN (:...child1)`
: `development.child1DnaId is null`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `development.child2DnaId IN (:...child2)`
: `development.child2DnaId is null`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `development.child3DnaId IN (:...child3)`
: `development.child3DnaId is null`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `development.child4DnaId IN (:...child4)`
: `development.child4DnaId is null`
: "1=1",
{
child4: _data.child4,
},
)
.select([
"development.id",
"development.projectName",
@ -2385,7 +2461,12 @@ export class DevelopmentController extends Controller {
dateStart: getDevelopment.dateStart,
dateEnd: getDevelopment.dateEnd,
totalDate: getDevelopment.totalDate,
developmentAddresss: getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()),
developmentAddresss:
getDevelopment.developmentAddresss == null
? null
: getDevelopment.developmentAddresss.sort(
(a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
),
};
return new HttpSuccess(_getDevelopment);
}
@ -2597,7 +2678,7 @@ export class DevelopmentController extends Controller {
startDate: x.dateStart,
endDate: x.dateEnd,
isDate: true,
developmentId: id
developmentId: id,
})
.then((x) => {
_data.isDone = true;
@ -2620,7 +2701,7 @@ export class DevelopmentController extends Controller {
startDate: x.dateStart,
endDate: x.dateEnd,
isDate: true,
developmentId: id
developmentId: id,
})
.then((x) => {
_data.isDone = true;
@ -2658,7 +2739,7 @@ export class DevelopmentController extends Controller {
relations: ["development", "development.developmentProjectTechniqueActuals"],
});
let isDevelopment70: boolean = false
let isDevelopment70: boolean = false;
const dev70Lists = [
"on_the_job_training",
"job_project_assignment",
@ -2671,18 +2752,18 @@ export class DevelopmentController extends Controller {
"benchmarking",
"problem_solving",
"team_working",
"other1"
"other1",
];
let isDevelopment20: boolean = false
let isDevelopment20: boolean = false;
const dev20Lists = [
"coaching",
"mentoring",
"team_meeting",
"consulting",
"feedback",
"other2"
"other2",
];
let isDevelopment10: boolean = false
let isDevelopment10: boolean = false;
const dev10Lists = [
"self_learning",
"classroom_training",
@ -2691,17 +2772,21 @@ export class DevelopmentController extends Controller {
"e_training",
"meeting",
"seminar",
"other3"
"other3",
];
await Promise.all(
getDevelopment.map(async (x) => {
const _data = Object.assign(new DevelopmentHistory(), x);
const techniqueActuals = x.development?.developmentProjectTechniqueActuals.flatMap(x => x.name) || [];
isDevelopment70 = techniqueActuals.length > 0 && dev70Lists.some(item => techniqueActuals.includes(item));
isDevelopment20 = techniqueActuals.length > 0 && dev20Lists.some(item => techniqueActuals.includes(item));
isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some(item => techniqueActuals.includes(item));
const techniqueActuals =
x.development?.developmentProjectTechniqueActuals.flatMap((x) => x.name) || [];
isDevelopment70 =
techniqueActuals.length > 0 && dev70Lists.some((item) => techniqueActuals.includes(item));
isDevelopment20 =
techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item));
isDevelopment10 =
techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item));
if (x.type == "OFFICER") {
await new CallAPI()
.PostData(request, "/org/profile/development", {

View file

@ -161,7 +161,13 @@ export class DevelopmentScholarshipController extends Controller {
@Query("year") year?: number,
@Query("scholarshipType") scholarshipType?: string,
) {
await new permission().PermissionList(request, "SYS_DEV_SCHOLARSHIP");
let _data = await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP");
await new CallAPI()
.PostData(request, "/org/finddna", _data)
.then((x) => {
_data = x;
})
.catch((x) => {});
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
@ -226,6 +232,16 @@ export class DevelopmentScholarshipController extends Controller {
);
}),
)
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `developmentScholarship.rootDnaId IN (:...root)`
: `developmentScholarship.rootDnaId is null`
: "1=1",
{
root: _data.root,
},
)
.orderBy("developmentScholarship.scholarshipYear", "DESC")
.addOrderBy("developmentScholarship.createdAt", "DESC")
.skip((page - 1) * pageSize)
@ -264,6 +280,7 @@ export class DevelopmentScholarshipController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null,
@ -282,6 +299,9 @@ export class DevelopmentScholarshipController extends Controller {
: null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
@ -426,6 +446,7 @@ export class DevelopmentScholarshipController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null,
@ -444,6 +465,9 @@ export class DevelopmentScholarshipController extends Controller {
: null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
@ -567,7 +591,10 @@ export class DevelopmentScholarshipController extends Controller {
* @param {string} id id
*/
@Get("admin/detail/{id}")
async GetDevelopemtScholarshipUserDetailAdminById(@Request() request: RequestWithUser, @Path() id: string) {
async GetDevelopemtScholarshipUserDetailAdminById(
@Request() request: RequestWithUser,
@Path() id: string,
) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({

View file

@ -5,6 +5,13 @@ import { PosType } from "./PosType";
@Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "id dna หน่วยงาน",
default: null,
})
rootDnaId: string;
@Column({
nullable: true,
comment: "id หน่วยงาน",
@ -137,6 +144,13 @@ export class DevelopmentScholarship extends EntityBase {
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน",
default: null,
})
guarantorRootDnaId: string;
@Column({
nullable: true,
comment: "id หน่วยงาน",
@ -576,6 +590,7 @@ export class DevelopmentScholarship extends EntityBase {
budgetSourceOther: string;
}
export class CreateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null;
root: string | null;
org: string | null;
@ -591,6 +606,7 @@ export class CreateDevelopmentScholarship {
posExecutive: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRootDnaId: string | null;
guarantorRootId: string | null;
guarantorRoot: string | null;
guarantorOrg: string | null;
@ -642,6 +658,7 @@ export class CreateDevelopmentScholarship {
}
export class UpdateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null;
root: string | null;
org: string | null;
@ -657,6 +674,7 @@ export class UpdateDevelopmentScholarship {
posExecutive: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRootDnaId?: string | null;
guarantorRootId?: string | null;
guarantorRoot?: string | null;
guarantorOrg?: string | null;

View file

@ -1,22 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateStrategyadddorder1743061489009 implements MigrationInterface {
name = 'UpdateStrategyadddorder1743061489009'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
await queryRunner.query(`ALTER TABLE \`strategyChild1\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`strategyChild1\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP COLUMN \`order\``);
}
}

View file

@ -1,36 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableActualGoalAndPlannedGoalPosition1744342850196 implements MigrationInterface {
name = 'UpdateTableActualGoalAndPlannedGoalPosition1744342850196'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_a9a864dd06eaa25edba8be8f24c\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP FOREIGN KEY \`FK_e08e337e5ddeb4942c72393ff58\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_4eef5d8c3ab92f7af4a762150a4\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP FOREIGN KEY \`FK_8e7e0bf6eebd99f58e9b47c6b05\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActualId\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActualId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlannedId\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlannedId\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActual\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActual\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlanned\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง & กลุ่มงาน'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlanned\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง & ระดับชั้นงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posLevelPlanned\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` DROP COLUMN \`posTypePlanned\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posLevelActual\``);
await queryRunner.query(`ALTER TABLE \`actualGoal\` DROP COLUMN \`posTypeActual\``);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posTypePlannedId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD \`posLevelPlannedId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posTypeActualId\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD \`posLevelActualId\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_8e7e0bf6eebd99f58e9b47c6b05\` FOREIGN KEY (\`posLevelPlannedId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`plannedGoalPosition\` ADD CONSTRAINT \`FK_4eef5d8c3ab92f7af4a762150a4\` FOREIGN KEY (\`posTypePlannedId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_e08e337e5ddeb4942c72393ff58\` FOREIGN KEY (\`posTypeActualId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`actualGoal\` ADD CONSTRAINT \`FK_a9a864dd06eaa25edba8be8f24c\` FOREIGN KEY (\`posLevelActualId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}

View file

@ -1,24 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590 implements MigrationInterface {
name = 'UpdateTableDevelopAddressAndDevelopScholashipAddFields1745290442590'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`addressType\` varchar(255) NULL COMMENT 'สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)'`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`country\` varchar(255) NULL COMMENT 'ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` varchar(255) NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentAddress\` CHANGE \`provinceName\` \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`useOfficialTime\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`useOfficialTime\` tinyint NOT NULL COMMENT 'ใช้เวลาราชการ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`country\``);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`addressType\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``);
}
}

View file

@ -1,16 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopScholashipEditType1745313881448 implements MigrationInterface {
name = 'UpdateTableDevelopScholashipEditType1745313881448'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` varchar(255) NULL COMMENT 'เงินอื่นๆ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`budgetSourceOther\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`budgetSourceOther\` int NULL COMMENT 'เงินอื่นๆ'`);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update300620256041750083465733 implements MigrationInterface {
name = 'Update300620256041750083465733'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id dna หน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootDnaId\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update300620256051750083913468 implements MigrationInterface {
name = 'Update300620256051750083913468'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootDnaId\``);
}
}