mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Add migration script to add sort field to checklists and their items
This commit is contained in:
parent
43a58c92ac
commit
6921452a7d
1 changed files with 26 additions and 0 deletions
|
@ -130,3 +130,29 @@ Migrations.add('add-member-isactive-field', () => {
|
|||
Boards.update(board._id, {$set: {members: newMemberSet}}, noValidate);
|
||||
});
|
||||
});
|
||||
|
||||
Migrations.add('add-sort-checklists', () => {
|
||||
Checklists.find().forEach((checklist, index) => {
|
||||
if (!checklist.hasOwnProperty('sort')) {
|
||||
Checklists.direct.update(
|
||||
checklist._id,
|
||||
{
|
||||
$set: {
|
||||
sort: index,
|
||||
newItemIndex: checklist.items.length,
|
||||
}
|
||||
},
|
||||
noValidate
|
||||
);
|
||||
}
|
||||
checklist.items.forEach(function(item, index) {
|
||||
if (!item.hasOwnProperty('sort')) {
|
||||
Checklists.direct.update(
|
||||
{ _id: checklist._id, "items._id": item._id },
|
||||
{ $set: { "items.$.sort": index } },
|
||||
noValidate
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue