Skip to content

Commit

Permalink
Merge pull request #5966 from nimrod-becker/backport_to_5_3
Browse files Browse the repository at this point in the history
Backport to 5.3: fixed upgrade script update_bucket_owner_account.js
  • Loading branch information
nimrod-becker authored Mar 30, 2020
2 parents 9f579d9 + 9440626 commit 25cd79b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/upgrade/upgrade_scripts/5.3.0/update_bucket_owner_account.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ const _ = require('lodash');
async function run({ dbg, mongo_client, system_store }) {
try {
const system_owner = _.get(system_store.data, 'systems.0.owner._id');
await system_store.make_changes({
update: {
buckets: [{
$find: {
owner_account: { $exists: false }
},
$set: {
owner_account: system_owner
}
}]
}
});
const buckets = system_store.data.buckets
.filter(b => !b.owner_account)
.map(b => ({
_id: b._id,
$set: { owner_account: system_owner }
}));
if (buckets.length > 0) {
dbg.log0(`updating owner_account (${system_owner}) to these buckets: ${buckets.map(b => b._id).join(', ')}`);
await system_store.make_changes({ update: { buckets } });
} else {
dbg.log0('there are no buckets that need owner_account update');
}
} catch (err) {
dbg.error('got error while updating bucket owner_account:', err);
throw err;
Expand Down

0 comments on commit 25cd79b

Please sign in to comment.