summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-10-13 23:51:54 +0300
committerLauri Ojansivu <x@xet7.org>2018-10-13 23:51:54 +0300
commit8cd5f7c185d31849c12ec0d9188120a6cb3e361e (patch)
treedc451421cb3e307d2f15a76d5b8d54008ba18dbd
parentbedd3767cece1784c9622b5c9d17d61251ba61e1 (diff)
downloadwekan-8cd5f7c185d31849c12ec0d9188120a6cb3e361e.tar.gz
wekan-8cd5f7c185d31849c12ec0d9188120a6cb3e361e.tar.bz2
wekan-8cd5f7c185d31849c12ec0d9188120a6cb3e361e.zip
- [Fix deleting Custom Fields, removing broken references](https://github.com/wekan/wekan/issues/1872).
Thanks to Akuket and Clement87 !
-rw-r--r--models/customFields.js6
-rw-r--r--server/migrations.js18
2 files changed, 24 insertions, 0 deletions
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);
+});
+