From af6cd7ce05cde957690dba7011d04d569125690c Mon Sep 17 00:00:00 2001 From: "sachin.patel" Date: Fri, 6 Sep 2019 12:22:13 +0100 Subject: [PATCH] =?UTF-8?q?ER-1242=20=F0=9F=93=9C=20-=20Adding=20changeScr?= =?UTF-8?q?ipts=20for=20the=20changing=20communication=20messages=20status?= =?UTF-8?q?es=20+semver:=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._updateStatusFromFailedDeliveryToNotSent.js | 18 ++++++++++++++++++ ...Messages_updateStatusFromUnsentToPending.js | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/Data/Recruit.ChangeScripts/010-communicationMessages_updateStatusFromFailedDeliveryToNotSent.js create mode 100644 src/Data/Recruit.ChangeScripts/020-communicationMessages_updateStatusFromUnsentToPending.js diff --git a/src/Data/Recruit.ChangeScripts/010-communicationMessages_updateStatusFromFailedDeliveryToNotSent.js b/src/Data/Recruit.ChangeScripts/010-communicationMessages_updateStatusFromFailedDeliveryToNotSent.js new file mode 100644 index 0000000000..ce5b0a4aed --- /dev/null +++ b/src/Data/Recruit.ChangeScripts/010-communicationMessages_updateStatusFromFailedDeliveryToNotSent.js @@ -0,0 +1,18 @@ +{ + print("Start updating communicationMessages collection documents which have a status of 'FailedDelivery' to 'NotSent'."); + + let writeResult = db.communicationMessages.updateMany({ + "status": "FailedDelivery" + }, { + "$set": { "status": "NotSent" } + }); + + if (writeResult.hasWriteConcernError()) { + printjson(writeResult.writeConcernError); + quit(14); + } + + print(`Found ${writeResult.matchedCount} communicationMessages with status 'FailedDelivery' of which ${writeResult.modifiedCount} have now been updated to have status 'NotSent'.`); + + print("Finished updating communicationMessages collection documents which have a status of 'FailedDelivery' to 'NotSent'."); +} \ No newline at end of file diff --git a/src/Data/Recruit.ChangeScripts/020-communicationMessages_updateStatusFromUnsentToPending.js b/src/Data/Recruit.ChangeScripts/020-communicationMessages_updateStatusFromUnsentToPending.js new file mode 100644 index 0000000000..9c4053277c --- /dev/null +++ b/src/Data/Recruit.ChangeScripts/020-communicationMessages_updateStatusFromUnsentToPending.js @@ -0,0 +1,18 @@ +{ + print("Start updating communicationMessages collection documents which have a status of 'Unsent' to 'Pending'."); + + let writeResult = db.communicationMessages.updateMany({ + "status": "Unsent" + }, { + "$set": { "status": "Pending" } + }); + + if (writeResult.hasWriteConcernError()) { + printjson(writeResult.writeConcernError); + quit(14); + } + + print(`Found ${writeResult.matchedCount} communicationMessages with status 'Unsent' of which ${writeResult.modifiedCount} have now been updated to have status 'Pending'.`); + + print("Finished updating communicationMessages collection documents which have a status of 'Unsent' to 'Pending'."); +} \ No newline at end of file