Migration script for removing old dailies histories

This commit is contained in:
Philip How
2013-03-08 00:20:46 +00:00
parent 50c5069224
commit 24c7677764

View File

@@ -0,0 +1,29 @@
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js
/**
* Remove duff histories for dailies
*/
db.users.find().forEach(function(user){
_.each(user.tasks, function(task, key){
// remove task history
if (task.type === "daily") {
task.history = []
}
});
try {
db.users.update(
{_id:user._id},
{$set:
{
'tasks' : user.tasks
}
},
{multi:true}
);
} catch(e) {
print(e);
}
})