-
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 #1699 from bcgov/feature/ALCS-1970
Add missing LFNG Reviews
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...ices/apps/alcs/src/providers/typeorm/migrations/1716326002959-add_missing_lfng_reviews.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,39 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddMissingLfngReviews1716326002959 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const results = (await queryRunner.query(` | ||
SELECT | ||
file_number | ||
FROM ( | ||
SELECT | ||
file_number, | ||
status_type_code, | ||
application_submission.uuid, | ||
alcs.get_current_status_for_application_submission_by_uuid (alcs.application_submission.uuid) ->> 'status_type_code' AS "current_status" | ||
FROM | ||
alcs.application_submission_to_submission_status | ||
LEFT JOIN alcs.application_submission ON application_submission.uuid = application_submission_to_submission_status.submission_uuid | ||
LEFT JOIN alcs.application_submission_review ON application_submission_review.application_file_number = application_submission.file_number | ||
WHERE | ||
status_type_code = 'REVG' | ||
AND application_submission_review.uuid IS NULL | ||
AND effective_date IS NOT NULL) a | ||
WHERE | ||
a.current_status = 'REVG'; | ||
`)) as { file_number: string }[]; | ||
|
||
for (const result of results) { | ||
await queryRunner.query(` | ||
INSERT INTO "alcs"."application_submission_review" | ||
("audit_deleted_date_at", "audit_created_at", "audit_updated_at", "audit_created_by", "audit_updated_by", "uuid", "local_government_file_number", "first_name", "last_name", "position", "department", "phone_number", "email", "is_ocp_designation", "ocp_bylaw_name", "ocp_designation", "ocp_consistent", "is_subject_to_zoning", "zoning_bylaw_name", "zoning_designation", "zoning_minimum_lot_size", "is_zoning_consistent", "is_authorized", "application_file_number", "created_by_uuid") VALUES | ||
(NULL, NOW(), NULL, 'seed-migration', NULL, DEFAULT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ${result.file_number}, NULL); | ||
`); | ||
console.log(`Add Review for Application ${result.file_number}`); | ||
} | ||
} | ||
|
||
public async down(): Promise<void> { | ||
//Nope | ||
} | ||
} |