From 2dc6e150244e4fc30872a77e055af33af27f8d47 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Mon, 14 Sep 2020 01:21:50 -0500 Subject: [PATCH] Mig: add migration cfs:* -> ostrio:files --- server/migrations.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server/migrations.js b/server/migrations.js index 5b6f05296..fdcac9a4f 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -1119,3 +1119,38 @@ Migrations.add('add-card-details-show-lists', () => { noValidateMulti, ); }); + +Migrations.add( + 'adapt-attachments-to-ostrio-files-api-using-meta-and-drp-cfs-leacy', + () => { + Attachments.find().forEach(file => { + Attachments.update( + file._id, + { + $set: { + 'meta.boardId': file.boardId, + 'meta.cardId': file.cardId, + 'meta.listId': file.listId, + 'meta.swimlaneId': file.swimlaneId, + }, + }, + noValidate, + ); + }); + Attachments.update( + {}, + { + $unset: { + original: '', // cfs:* legacy + copies: '', // cfs:* legacy + failures: '', // cfs:* legacy + boardId: '', + cardId: '', + listId: '', + swimlaneId: '', + }, + }, + noValidateMulti, + ); + }, +);