Skip to content

Commit

Permalink
Merge pull request #1699 from bcgov/feature/ALCS-1970
Browse files Browse the repository at this point in the history
Add missing LFNG Reviews
  • Loading branch information
dhaselhan authored May 21, 2024
2 parents 0014df2 + 8c83227 commit 5d4c936
Showing 1 changed file with 39 additions and 0 deletions.
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
}
}

0 comments on commit 5d4c936

Please sign in to comment.