Explorar o código

Connect only if not connected

Taichi Masuyama %!s(int64=4) %!d(string=hai) anos
pai
achega
439daf0121

+ 3 - 1
packages/app/src/migrations/20210913153942-migrate-slack-app-integration-schema.js

@@ -20,7 +20,9 @@ defaultSupportedCommandsNameForSingleUse.forEach((commandName) => {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    await mongoose.connect(getMongoUri(), mongoOptions);
+    if (mongoose.connection.readyState === 1) {
+      await mongoose.connect(getMongoUri(), mongoOptions);
+    }
 
 
     const SlackAppIntegration = getModelSafely('SlackAppIntegration') || require('~/server/models/slack-app-integration')();
     const SlackAppIntegration = getModelSafely('SlackAppIntegration') || require('~/server/models/slack-app-integration')();