From 8cd5f7c185d31849c12ec0d9188120a6cb3e361e Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sat, 13 Oct 2018 23:51:54 +0300 Subject: - [Fix deleting Custom Fields, removing broken references](https://github.com/wekan/wekan/issues/1872). Thanks to Akuket and Clement87 ! --- models/customFields.js | 6 ++++++ server/migrations.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/models/customFields.js b/models/customFields.js index 6c5fe7c4..38481d8c 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -71,6 +71,12 @@ if (Meteor.isServer) { Activities.remove({ customFieldId: doc._id, }); + + Cards.update( + {'boardId': doc.boardId, 'customFields._id': doc._id}, + {$pull: {'customFields': {'_id': doc._id}}}, + {multi: true} + ); }); } diff --git a/server/migrations.js b/server/migrations.js index 91c34be2..ac33d836 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -321,3 +321,21 @@ Migrations.add('add-subtasks-allowed', () => { }, }, noValidateMulti); }); + +Migrations.add('remove-tag', () => { + Users.update({ + }, { + $unset: { + 'profile.tags':1, + }, + }, noValidateMulti); +}); + +Migrations.add('remove-customFields-references-broken', () => { + Cards.update({'customFields.$value': null}, + { $pull: { + customFields: {value: null}, + }, + }, noValidateMulti); +}); + -- cgit v1.2.3-1-g7c22