Skip to content

Commit

Permalink
Merge pull request #1965 from bcgov/feature/ALCS-2147-fix
Browse files Browse the repository at this point in the history
Fix possibly adding deleted tags
  • Loading branch information
trslater authored Nov 6, 2024
2 parents 935fa4a + 46bcca8 commit a2c7ceb
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ export class MigrateDecisionNaruSubtypesToTags1730926552631 implements Migration
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`
with ranked_components as (
select ad.application_uuid,
adc.naru_subtype_code,
rank() over (partition by ad.application_uuid order by ad.date)
from alcs.application_decision ad
join alcs.application_decision_component adc on adc.application_decision_uuid = ad."uuid"
where ad.is_draft is false
and adc.application_decision_component_type_code = 'NARU'
and adc.naru_subtype_code is not null
select ad.application_uuid,
adc.naru_subtype_code,
rank() over (partition by ad.application_uuid order by ad.date)
from alcs.application_decision ad
join alcs.application_decision_component adc on adc.application_decision_uuid = ad."uuid"
where ad.is_draft is false
and adc.application_decision_component_type_code = 'NARU'
and adc.naru_subtype_code is not null
)
insert into alcs.application_tag (application_uuid, tag_uuid)
select rc.application_uuid, t."uuid"
Expand All @@ -22,6 +22,7 @@ export class MigrateDecisionNaruSubtypesToTags1730926552631 implements Migration
when rc.naru_subtype_code = 'TOUR' then 'Tourism'
end = t.name
where rc.rank = 1
and t.audit_deleted_date_at is null
on conflict do nothing
`);
}
Expand Down

0 comments on commit a2c7ceb

Please sign in to comment.