Jelajahi Sumber

create migration file

itizawa 6 tahun lalu
induk
melakukan
661f1a531a
1 mengubah file dengan 24 tambahan dan 0 penghapusan
  1. 24 0
      src/migrations/20200512005851-remove-behavior-type.js

+ 24 - 0
src/migrations/20200512005851-remove-behavior-type.js

@@ -0,0 +1,24 @@
+require('module-alias/register');
+const logger = require('@alias/logger')('growi:migrate:remove-behavior-type');
+
+const mongoose = require('mongoose');
+const config = require('@root/config/migrate');
+
+const { getModelSafely } = require('@commons/util/mongoose-utils');
+
+module.exports = {
+  async up(db, client) {
+    logger.info('Apply migration');
+    mongoose.connect(config.mongoUri, config.mongodb.options);
+
+    const Config = getModelSafely('Config') || require('@server/models/config')();
+
+    await Config.findOneAndDelete({ key: 'customize:behavior' }); // remove behavior
+
+    logger.info('Migration has successfully applied');
+  },
+
+  async down(db, client) {
+    // do not rollback
+  },
+};