migrate
This commit is contained in:
parent
7b9172c93f
commit
188a028bec
2 changed files with 47 additions and 6 deletions
|
|
@ -12,12 +12,12 @@ export class OFFICER {
|
|||
// })
|
||||
// RET_YEAR: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "text",
|
||||
default: null,
|
||||
})
|
||||
ID: string;
|
||||
// @Column({
|
||||
// nullable: true,
|
||||
// type: "text",
|
||||
// default: null,
|
||||
// })
|
||||
// ID: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddViewProfileEmployeeEvaluation1739768503699 implements MigrationInterface {
|
||||
name = 'AddViewProfileEmployeeEvaluation1739768503699'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE VIEW \`view_profile_employee_evaluation\` AS SELECT
|
||||
\`profileEmployeeId\`,
|
||||
\`period\`,
|
||||
\`year\`,
|
||||
\`employeePosMaster\`.\`orgRootId\`,
|
||||
\`employeePosMaster\`.\`orgChild1Id\`,
|
||||
\`employeePosMaster\`.\`orgChild2Id\`,
|
||||
\`employeePosMaster\`.\`orgChild3Id\`,
|
||||
\`employeePosMaster\`.\`orgChild4Id\`,
|
||||
COUNT(*) AS recordCount,
|
||||
SUM(pointSum) AS totalPointSum,
|
||||
SUM(pointSum) / COUNT(*) AS result
|
||||
FROM \`profileAssessment\`
|
||||
LEFT JOIN \`profileEmployee\` ON \`profileAssessment\`.\`profileEmployeeId\` = \`profileEmployee\`.\`id\`
|
||||
LEFT JOIN \`employeePosMaster\` ON \`profileEmployee\`.\`id\` = \`employeePosMaster\`.\`current_holderId\`
|
||||
LEFT JOIN \`orgRevision\` ON \`employeePosMaster\`.\`orgRevisionId\` = \`orgRevision\`.\`id\`
|
||||
WHERE \`period\` IS NOT NULL
|
||||
AND \`orgRevision\`.\`orgRevisionIsCurrent\` = TRUE
|
||||
GROUP BY \`profileEmployeeId\`, \`period\`, \`year\`,
|
||||
\`employeePosMaster\`.\`orgRootId\`,
|
||||
\`employeePosMaster\`.\`orgChild1Id\`,
|
||||
\`employeePosMaster\`.\`orgChild2Id\`,
|
||||
\`employeePosMaster\`.\`orgChild3Id\`,
|
||||
\`employeePosMaster\`.\`orgChild4Id\`
|
||||
ORDER BY \`year\` DESC, \`period\` ASC;
|
||||
`);
|
||||
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_profile_employee_evaluation","SELECT \n `profileEmployeeId`,\n `period`,\n `year`,\n `employeePosMaster`.`orgRootId`,\n `employeePosMaster`.`orgChild1Id`,\n `employeePosMaster`.`orgChild2Id`,\n `employeePosMaster`.`orgChild3Id`,\n `employeePosMaster`.`orgChild4Id`, \n COUNT(*) AS recordCount, \n SUM(pointSum) AS totalPointSum, \n SUM(pointSum) / COUNT(*) AS result\n FROM `profileAssessment` \n LEFT JOIN `profileEmployee` ON `profileAssessment`.`profileEmployeeId` = `profileEmployee`.`id`\n LEFT JOIN `employeePosMaster` ON `profileEmployee`.`id` = `employeePosMaster`.`current_holderId`\n LEFT JOIN `orgRevision` ON `employeePosMaster`.`orgRevisionId` = `orgRevision`.`id`\n WHERE `period` IS NOT NULL\n AND `orgRevision`.`orgRevisionIsCurrent` = TRUE\n GROUP BY `profileEmployeeId`, `period`, `year`, \n `employeePosMaster`.`orgRootId`, \n `employeePosMaster`.`orgChild1Id`, \n `employeePosMaster`.`orgChild2Id`, \n `employeePosMaster`.`orgChild3Id`, \n `employeePosMaster`.`orgChild4Id`\n ORDER BY `year` DESC, `period` ASC;"]);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_profile_employee_evaluation","bma_ehr_organization_demo"]);
|
||||
await queryRunner.query(`DROP VIEW \`view_profile_employee_evaluation\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue