-
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.
Merge pull request #1967 from bcgov/feature/ALCS-2276
Add tags based on non-approved NARU submissions
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...pps/alcs/src/providers/typeorm/migrations/1731087728950-add_naru_sub_tags_from_answers.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,52 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddNaruSubTagsFromAnswers1731087728950 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
queryRunner.query(` | ||
insert into | ||
alcs.application_tag (application_uuid, tag_uuid) | ||
select | ||
distinct a."uuid", | ||
t."uuid" | ||
from | ||
alcs.application_submission as2 | ||
join alcs.application a on a.file_number = as2.file_number | ||
left join alcs.application_decision ad on ad.application_uuid = a."uuid" | ||
join alcs.tag t on ( | ||
( | ||
as2.naru_will_be_over_five_hundred_m2 | ||
and t."name" = 'Principal Residence > 500m2' | ||
) | ||
or ( | ||
as2.naru_will_have_temporary_foreign_worker_housing | ||
and t."name" = 'Temporary Foreign Worker Housing' | ||
) | ||
or ( | ||
as2.naru_will_retain_residence | ||
and t."name" = 'Reside & Replace' | ||
) | ||
or ( | ||
as2.naru_will_have_additional_residence | ||
and t."name" = 'Additional Residence' | ||
) | ||
or ( | ||
as2.naru_will_import_fill | ||
and t."name" = 'Fill Placement' | ||
) | ||
) | ||
where | ||
t.audit_deleted_date_at is null | ||
group by | ||
a."uuid", | ||
t."uuid" | ||
having | ||
count( | ||
case | ||
when ad.outcome_code = 'APPR' then 1 | ||
end | ||
) = 0 on conflict do nothing; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {} | ||
} |