-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7714762
commit 23df85d
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
apps/api/src/migration/1727200471805-AddBackReportRoleToHA.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddBackReportRoleToHA1727200471805 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
INSERT INTO employee_roles_role (employee_id, role_id) | ||
SELECT e.id, r.id | ||
FROM employee e | ||
JOIN ien_ha_pcn ha ON ha.title = e.organization | ||
JOIN role r ON r.slug = 'reporting' | ||
WHERE NOT EXISTS ( | ||
SELECT 1 | ||
FROM employee_roles_role err | ||
WHERE err.employee_id = e.id | ||
AND err.role_id = r.id | ||
); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DELETE FROM employee_roles_role err | ||
USING employee e, role r, ien_ha_pcn ha | ||
WHERE | ||
e.id = err.employee_id AND | ||
ha.title = e.organization AND | ||
r.id = err.role_id AND | ||
r.slug = 'reporting'; | ||
`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters