Skip to content

Commit 1e44358

Browse files
authored
Merge pull request #2075 from bcgov/hotfix/ALCS-2478-add-date-to-single-date-conditions
ALCS-2478 Add date to the single date conditions
2 parents 42c7dbd + e549089 commit 1e44358

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class AddingDateToConditions1737579030699 implements MigrationInterface {
4+
5+
public async up(queryRunner: QueryRunner): Promise<void> {
6+
await queryRunner.query(`
7+
WITH conditions AS
8+
(
9+
SELECT c.uuid, c.type_code, t.date_type, COUNT(d.uuid) AS dates_count
10+
FROM alcs.application_decision_condition c
11+
INNER JOIN alcs.application_decision_condition_type t ON t.code = c.type_code
12+
LEFT OUTER JOIN alcs.application_decision_condition_date d ON d.condition_uuid = c.uuid
13+
WHERE
14+
date_type = 'Single'
15+
GROUP BY c.uuid, c.type_code, t.date_type
16+
HAVING COUNT(d.uuid) = 0
17+
)
18+
INSERT INTO alcs.application_decision_condition_date
19+
(
20+
audit_created_at,
21+
audit_updated_at,
22+
audit_created_by,
23+
date,
24+
comment,
25+
condition_uuid,
26+
completed_date
27+
)
28+
SELECT
29+
now(),
30+
now(),
31+
'migration_seed',
32+
null,
33+
null,
34+
conditions.uuid,
35+
null
36+
FROM conditions;
37+
`);
38+
}
39+
40+
public async down(queryRunner: QueryRunner): Promise<void> {
41+
// N/A
42+
}
43+
44+
}

0 commit comments

Comments
 (0)