Skip to content

Commit

Permalink
Merge pull request #136 from edx/feanil/update_context_migration
Browse files Browse the repository at this point in the history
Use bulk operation instead.
  • Loading branch information
feanil committed Aug 19, 2015
2 parents 1dff2db + 0575888 commit 634612a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions scripts/db/migrate-008-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ db.contents.ensureIndex({ _type: 1, course_id: 1, context: 1, pinned: -1, create
db.contents.ensureIndex({ _type: 1, commentable_id: 1, context: 1, pinned: -1, created_at: -1 }, {background: true})

print ("Adding context to all comment threads where it does not yet exist\n");
db.contents.update(
{_type: "CommentThread", context: {$exists: false}},
{$set: {context: "course"}},
{multi: true}
);
var bulk = db.contents.initializeUnorderedBulkOp();
bulk.find( {_type: "CommentThread", context: {$exists: false}} ).update( {$set: {context: "course"}} );
bulk.execute();
printjson (db.runCommand({ getLastError: 1, w: "majority", wtimeout: 5000 } ));

0 comments on commit 634612a

Please sign in to comment.