diff --git a/migrations/20131117_fix_task_types.js b/migrations/20131117_fix_task_types.js new file mode 100644 index 0000000000..14d86cb55f --- /dev/null +++ b/migrations/20131117_fix_task_types.js @@ -0,0 +1,18 @@ +// TODO figure out why this is happening in the first place + +db.users.find({},{habits:1, dailys:1, todos:1, rewards:1}).forEach(function(user){ + _.each(user.habits, function(task){ + task.type = 'habit'; + }) + _.each(user.dailys, function(task){ + task.type = 'daily'; + }) + _.each(user.todos, function(task){ + task.type = 'todo'; + }) + _.each(user.rewards, function(task){ + task.type = 'reward'; + }) + + db.users.update({_id:user._id}, {$set:{habits: user.habits, dailys: user.dailys, todos: user.todos, rewards: user.rewards}}); +});