Add checklist items model, migration and publication

This commit is contained in:
Andrés Manelli 2018-03-19 00:25:19 -03:00
parent 83848dbee2
commit bf7de463f1
4 changed files with 116 additions and 26 deletions

View file

@ -187,3 +187,24 @@ Migrations.add('add-views', () => {
}
});
});
Migrations.add('add-checklist-items', () => {
Checklists.find().forEach((checklist) => {
// Create new items
_.sortBy(checklist.items, 'sort').forEach((item) => {
ChecklistItems.direct.insert({
title: item.title,
sort: item.sort,
isFinished: item.isFinished,
checklistId: checklist._id,
cardId: checklist.cardId,
});
});
// Delete old ones
Checklists.direct.update({ _id: checklist._id },
{ $unset: { items : 1 } },
noValidate
);
});
});