mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-15 12:07:43 +00:00
add completed/todo merge migration a la @toebu
This commit is contained in:
parent
c2fddaab49
commit
9337414224
1 changed files with 15 additions and 0 deletions
15
migrations/20130128_merge_completed_todo_ids.js
Normal file
15
migrations/20130128_merge_completed_todo_ids.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
db.users.find({ completedIds: { $exists: true } }).forEach(function(user) {
|
||||
var newTodoIds = user.todoIds;
|
||||
user.completedIds.forEach(function(value) {
|
||||
if (newTodoIds.indexOf(value) === -1) {
|
||||
newTodoIds.push(value)
|
||||
}
|
||||
});
|
||||
db.users.update(
|
||||
{ _id: user._id },
|
||||
{
|
||||
$set: { todoIds: newTodoIds },
|
||||
$unset: { completedIds: 1 }
|
||||
}
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue