Prechádzať zdrojové kódy

- [Fix deleting Custom Fields, removing broken references](https://github.com/wekan/wekan/issues/1872).

Thanks to Akuket and Clement87 !
Lauri Ojansivu 6 rokov pred
rodič
commit
8cd5f7c185
2 zmenil súbory, kde vykonal 24 pridanie a 0 odobranie
  1. 6 0
      models/customFields.js
  2. 18 0
      server/migrations.js

+ 6 - 0
models/customFields.js

@@ -71,6 +71,12 @@ if (Meteor.isServer) {
     Activities.remove({
     Activities.remove({
       customFieldId: doc._id,
       customFieldId: doc._id,
     });
     });
+
+    Cards.update(
+      {'boardId': doc.boardId, 'customFields._id': doc._id},
+      {$pull: {'customFields': {'_id': doc._id}}},
+      {multi: true}
+    );
   });
   });
 }
 }
 
 

+ 18 - 0
server/migrations.js

@@ -321,3 +321,21 @@ Migrations.add('add-subtasks-allowed', () => {
     },
     },
   }, noValidateMulti);
   }, 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);
+});
+