浏览代码

Add a migration to add a sort field to the boards model

boeserwolf 5 年之前
父节点
当前提交
9f396e9038
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      server/migrations.js

+ 12 - 0
server/migrations.js

@@ -1033,3 +1033,15 @@ Migrations.add('add-description-text-allowed', () => {
     noValidateMulti,
   );
 });
+
+Migrations.add('add-sort-field-to-boards', () => {
+  Boards.find().forEach((board, index) => {
+  if (!board.hasOwnProperty('sort')) {
+      Boards.direct.update(
+        board._id,
+        { $set: { sort: index } },
+        noValidate
+      );
+    }
+  });
+});