mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
Migration script for removing old dailies histories
This commit is contained in:
29
migrations/20130307_remove_duff_histories.js
Normal file
29
migrations/20130307_remove_duff_histories.js
Normal 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);
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user