diff --git a/migrations/20131028_cleanup_deleted_tags.js b/migrations/20131028_cleanup_deleted_tags.js new file mode 100644 index 0000000000..165088dc6a --- /dev/null +++ b/migrations/20131028_cleanup_deleted_tags.js @@ -0,0 +1,17 @@ +_.each(db.users.find(), function(user){ + var tags = user.tags; + + _.each(user.tasks, function(task){ + _.each(task.tags, function(val, key){ + _.each(tags, function(tag){ + if(key == tag.id) delete task.tags[key]; + }); + }; + }); + + try { + db.users.update({_id:user._id}, user); + } catch(e) { + print(e); + } +});