From 2f01e1d56b4c2e3ef3ff40cf850ee59c8a7f5fd7 Mon Sep 17 00:00:00 2001 From: David <62899351+davidclaveau@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:01:06 -0700 Subject: [PATCH] update migration for ENV_EPD and update authors --- .../20230912181649-updateIssuingAgencyToCode.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/migrations/20230912181649-updateIssuingAgencyToCode.js b/api/migrations/20230912181649-updateIssuingAgencyToCode.js index 43330912b..35516c35f 100644 --- a/api/migrations/20230912181649-updateIssuingAgencyToCode.js +++ b/api/migrations/20230912181649-updateIssuingAgencyToCode.js @@ -55,10 +55,11 @@ exports.up = async function (db) { { $and: [ { issuingAgency: 'Ministry of Environment and Climate Change Strategy' }, + { author: 'Ministry of Environment and Climate Change Strategy' }, { 'legislation.act': { $in: [LegislationActs.ACT_Env_Management, LegislationActs.ACT_Int_Pest_Management] } } ] }, - { $set: { issuingAgency: 'AGENCY_ENV_EPD' } } + { $set: { issuingAgency: 'AGENCY_ENV_EPD', author: 'AGENCY_ENV_EPD' } } ); console.log(` ***** Updated records in collection: ${collection} *****`); @@ -73,8 +74,13 @@ exports.up = async function (db) { for (const agency of agencies) { // Update issuingAgency and author fields for the agency await currentCollection.updateMany( - { issuingAgency: agency['agencyName'] }, - { $set: { issuingAgency: agency['agencyCode'] } } + { + $and: [ + { issuingAgency: agency['agencyName'] }, + { author: agency['agencyName'] } + ] + }, + { $set: { issuingAgency: agency['agencyCode'], author: agency['agencyCode'] } } ); console.log(` ***** Updated collection: ${collection} for agency: ${agency['agencyName']} *****`);