Skip to content

Commit

Permalink
update migration for ENV_EPD and update authors
Browse files Browse the repository at this point in the history
  • Loading branch information
davidclaveau committed Oct 2, 2023
1 parent e5bfc3a commit 2f01e1d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/migrations/20230912181649-updateIssuingAgencyToCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} *****`);
Expand All @@ -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']} *****`);
Expand Down

0 comments on commit 2f01e1d

Please sign in to comment.