Просмотр исходного кода

migration down script and edit migration log

mizozobu 6 лет назад
Родитель
Сommit
40461f594b

+ 2 - 2
src/migrations/20180927102719-init-serverurl.js

@@ -79,7 +79,7 @@ module.exports = {
   },
 
   async down(db) {
-    logger.info('Undo migration');
+    logger.info('Rollback migration');
     mongoose.connect(config.mongoUri, config.mongodb.options);
 
     const Config = getModelSafely('Config') || require('@server/models/config')();
@@ -90,7 +90,7 @@ module.exports = {
       key: 'app:siteUrl',
     });
 
-    logger.info('Migration has successfully undoed');
+    logger.info('Migration has been successfully rollbacked');
   },
 
 };

+ 2 - 2
src/migrations/20181019114028-abolish-page-group-relation.js

@@ -72,7 +72,7 @@ module.exports = {
   },
 
   async down(db) {
-    logger.info('Undo migration');
+    logger.info('Rollback migration');
     mongoose.connect(config.mongoUri, config.mongodb.options);
 
     const Page = getModelSafely('Page') || require('@server/models/page');
@@ -109,7 +109,7 @@ module.exports = {
 
     await db.collection('pagegrouprelations').insertMany(insertDocs);
 
-    logger.info('Migration has successfully undoed');
+    logger.info('Migration has been successfully rollbacked');
   },
 
 };

+ 13 - 3
src/migrations/20190618055300-abolish-crowi-classic-auth.js

@@ -28,8 +28,18 @@ module.exports = {
     next();
   },
 
-  down(db, next) {
-    // do not rollback
-    next();
+  async down(db, next) {
+    logger.info('Rollback migration');
+    mongoose.connect(config.mongoUri, config.mongodb.options);
+
+    const Config = getModelSafely('Config') || require('@server/models/config')();
+
+    await Config.findOneAndUpdate(
+      { ns: 'crowi', key: 'security:isEnabledPassport' },
+      { ns: 'crowi', key: 'security:isEnabledPassport', value: JSON.stringify(false) },
+      { upsert: true },
+    );
+
+    logger.info('Migration has been successfully rollbacked');
   },
 };

+ 2 - 2
src/migrations/20190618104011-add-config-app-installed.js

@@ -48,7 +48,7 @@ module.exports = {
   },
 
   async down(db) {
-    logger.info('Undo migration');
+    logger.info('Rollback migration');
     mongoose.connect(config.mongoUri, config.mongodb.options);
 
     const Config = getModelSafely('Config') || require('@server/models/config')();
@@ -59,6 +59,6 @@ module.exports = {
       key: 'app:installed',
     });
 
-    logger.info('Migration has successfully undoed');
+    logger.info('Migration has been successfully rollbacked');
   },
 };