Yuki Takei 6 лет назад
Родитель
Сommit
bcf3e6be47
1 измененных файлов с 41 добавлено и 0 удалено
  1. 41 0
      src/migrations/20190624110950-fill-last-update-user.js

+ 41 - 0
src/migrations/20190624110950-fill-last-update-user.js

@@ -0,0 +1,41 @@
+require('module-alias/register');
+const logger = require('@alias/logger')('growi:migrate:abolish-page-group-relation');
+
+const mongoose = require('mongoose');
+const config = require('@root/config/migrate');
+
+module.exports = {
+
+  async up(db) {
+    logger.info('Apply migration');
+    mongoose.connect(config.mongoUri, config.mongodb.options);
+
+    /*
+    await db.collection('pages').aggregate([
+      {
+        $match: {
+          $or: [
+            { lastUpdateUser: { $exists: false } },
+            { lastUpdateUser: { $eq: null } },
+          ],
+        },
+      },
+      {
+        $addFields: {
+          lastUpdateUser: '$creator',
+        },
+      },
+    ])
+      .out('pages')
+      .toArray();
+
+    */
+
+    logger.info('Migration has successfully applied');
+  },
+
+  down(db) {
+    // do not rollback
+  },
+
+};