Tweak fix-patch-originals script

This commit is contained in:
Scott Erickson 2016-09-19 09:51:04 -07:00
parent 4c277a1b1a
commit 7efccfeac4

View file

@ -10,15 +10,18 @@ VERSIONED_COLLECTIONS = {
db.patches.find({created:{$gt: '2016-09-08'}}).forEach(function(patch) {
if (!VERSIONED_COLLECTIONS[patch.target.collection]) {
print('skip', patch.target.collection);
//print('skip', patch.target.collection);
return;
}
if (patch.target.original && patch.target.id && patch.target.original.equals(patch.target.id)) {
target = VERSIONED_COLLECTIONS[patch.target.collection].findOne({_id: patch.target.original});
print('found original', target, target._id, target.original);
print('Update patch:',
JSON.stringify({_id: patch._id}),
JSON.stringify({$set: {'target.original': target.original}})
);
db.patches.update({_id: patch._id}, {$set: {'target.original': target.original}});
}
else {
print('They are different, they are fine');
//print('They are different, they are fine');
}
});