attachment copy changes now the boardId, listId and swimlaneId in the collection data

- fixing admin attachment view, copied card attachments were wrong if copied to another board / list / swimlane
This commit is contained in:
Martin Filser 2023-02-26 21:48:54 +01:00
parent 0261bb592e
commit 2eadd3eb8b
2 changed files with 19 additions and 3 deletions

View file

@ -1420,3 +1420,18 @@ Migrations.add('migrate-attachment-migration-fix-source-import', () => {
noValidateMulti
);
});
Migrations.add('attachment-cardCopy-fix-boardId-etc', () => {
Attachments.find( {"meta.source": "copy"} ).forEach(_attachment => {
const cardId = _attachment.meta.cardId;
const card = Cards.findOne(cardId);
console.log("update attachment id: ", _attachment._id);
Attachments.update(_attachment._id, {
$set: {
"meta.boardId": card.boardId,
"meta.listId": card.listId,
"meta.swimlaneId": card.swimlaneId,
}
});
});
});