Parcourir la source

Refactor mongoose connection to use async/await

Yuki Takei il y a 1 an
Parent
commit
304c593087
40 fichiers modifiés avec 59 ajouts et 60 suppressions
  1. 1 1
      apps/app/src/migrations/20180926134048-make-email-unique.js
  2. 2 3
      apps/app/src/migrations/20180927102719-init-serverurl.js
  3. 2 2
      apps/app/src/migrations/20181019114028-abolish-page-group-relation.js
  4. 1 1
      apps/app/src/migrations/20190618055300-abolish-crowi-classic-auth.js
  5. 2 2
      apps/app/src/migrations/20190618104011-add-config-app-installed.js
  6. 1 1
      apps/app/src/migrations/20190619055421-adjust-page-grant.js
  7. 1 1
      apps/app/src/migrations/20190624110950-fill-last-update-user.js
  8. 1 1
      apps/app/src/migrations/20190629193445-make-root-page-public.js
  9. 1 1
      apps/app/src/migrations/20191102223900-drop-configs-indices.js
  10. 1 1
      apps/app/src/migrations/20191102223901-drop-pages-indices.js
  11. 1 1
      apps/app/src/migrations/20191126173016-adjust-pages-path.js
  12. 1 1
      apps/app/src/migrations/20191127023815-drop-wrong-index-of-page-tag-relation.js
  13. 1 1
      apps/app/src/migrations/20200402160380-remove-deleteduser-from-relationgroup.js
  14. 1 1
      apps/app/src/migrations/20200420160390-remove-crowi-layout.js
  15. 2 2
      apps/app/src/migrations/20200512005851-remove-behavior-type.js
  16. 1 1
      apps/app/src/migrations/20200514001356-update-theme-color-for-dark.js
  17. 1 1
      apps/app/src/migrations/20200620203632-normalize-locale-id.js
  18. 2 2
      apps/app/src/migrations/20200827045151-remove-layout-setting.js
  19. 2 2
      apps/app/src/migrations/20200828024025-copy-aws-setting.js
  20. 2 2
      apps/app/src/migrations/20200901034313-update-mail-transmission.js
  21. 2 2
      apps/app/src/migrations/20200903080025-remove-timeline-type.js.js
  22. 2 2
      apps/app/src/migrations/20200915035234-rename-s3-config.js
  23. 1 1
      apps/app/src/migrations/20210420160380-convert-double-to-date.js
  24. 2 2
      apps/app/src/migrations/20210830074539-update-configs-for-slackbot.js
  25. 1 1
      apps/app/src/migrations/20210906194521-slack-app-integration-set-default-value.js
  26. 2 2
      apps/app/src/migrations/20210921173042-add-is-trashed-field.js
  27. 2 2
      apps/app/src/migrations/20211005120030-slack-app-integration-rename-keys.js
  28. 2 2
      apps/app/src/migrations/20211005131430-config-without-proxy-command-permission-for-renaming.js
  29. 2 2
      apps/app/src/migrations/20211129125654-initialize-private-legacy-pages-named-query.js
  30. 2 2
      apps/app/src/migrations/20211227060705-revision-path-to-page-id-schema-migration--fixed-7549.js
  31. 2 2
      apps/app/src/migrations/20220131001218-convert-redirect-to-pages-to-page-redirect-documents.js
  32. 1 1
      apps/app/src/migrations/20220311011114-convert-page-delete-config.js
  33. 1 1
      apps/app/src/migrations/20220411114257-set-sparse-option-to-slack-member-id.js
  34. 1 1
      apps/app/src/migrations/20220613064207-add-attachment-type-to-existing-attachments.js
  35. 2 2
      apps/app/src/migrations/20221014130200-remove-customize-is-saved-states-of-tab-changes.js
  36. 1 1
      apps/app/src/migrations/20221219011829-remove-basic-auth-related-config.js
  37. 2 2
      apps/app/src/migrations/20230213090921-remove-presentation-configurations.js
  38. 2 2
      apps/app/src/migrations/20230731075753-add_installed_date_to_config.js
  39. 1 1
      apps/app/src/migrations/20231102012742-clean-user-ui-settings-collection.js
  40. 1 1
      apps/app/test/integration/global-setup.js

+ 1 - 1
apps/app/src/migrations/20180926134048-make-email-unique.js

@@ -11,7 +11,7 @@ module.exports = {
 
 
   async up(db, next) {
   async up(db, next) {
     logger.info('Start migration');
     logger.info('Start migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const User = userModelFactory();
     const User = userModelFactory();
 
 

+ 2 - 3
apps/app/src/migrations/20180927102719-init-serverurl.js

@@ -1,6 +1,5 @@
 import mongoose from 'mongoose';
 import mongoose from 'mongoose';
 
 
-// eslint-disable-next-line import/no-named-as-default
 import { Config } from '~/server/models/config';
 import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
@@ -21,7 +20,7 @@ module.exports = {
 
 
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // find 'app:siteUrl'
     // find 'app:siteUrl'
     const siteUrlConfig = await Config.findOne({
     const siteUrlConfig = await Config.findOne({
@@ -77,7 +76,7 @@ module.exports = {
 
 
   async down(db) {
   async down(db) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // remote 'app:siteUrl'
     // remote 'app:siteUrl'
     await Config.findOneAndDelete({
     await Config.findOneAndDelete({

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

@@ -31,7 +31,7 @@ module.exports = {
 
 
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const isPagegrouprelationsExists = await isCollectionExists(db, 'pagegrouprelations');
     const isPagegrouprelationsExists = await isCollectionExists(db, 'pagegrouprelations');
     if (!isPagegrouprelationsExists) {
     if (!isPagegrouprelationsExists) {
@@ -75,7 +75,7 @@ module.exports = {
 
 
   async down(db) {
   async down(db) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = pageModelFactory();
     const Page = pageModelFactory();
     const UserGroup = userGroupModelFactory();
     const UserGroup = userGroupModelFactory();

+ 1 - 1
apps/app/src/migrations/20190618055300-abolish-crowi-classic-auth.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:abolish-crowi-classic-auth');
 module.exports = {
 module.exports = {
   async up(db, next) {
   async up(db, next) {
     logger.info('Start migration');
     logger.info('Start migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // enable passport and delete configs for crowi classic auth
     // enable passport and delete configs for crowi classic auth
     await Promise.all([
     await Promise.all([

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

@@ -19,7 +19,7 @@ module.exports = {
 
 
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const User = userModelFactory();
     const User = userModelFactory();
 
 
@@ -49,7 +49,7 @@ module.exports = {
 
 
   async down(db) {
   async down(db) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // remote 'app:siteUrl'
     // remote 'app:siteUrl'
     await Config.findOneAndDelete({
     await Config.findOneAndDelete({

+ 1 - 1
apps/app/src/migrations/20190619055421-adjust-page-grant.js

@@ -10,7 +10,7 @@ module.exports = {
 
 
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = getPageModel();
     const Page = getPageModel();
 
 

+ 1 - 1
apps/app/src/migrations/20190624110950-fill-last-update-user.js

@@ -13,7 +13,7 @@ module.exports = {
 
 
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = getPageModel();
     const Page = getPageModel();
 
 

+ 1 - 1
apps/app/src/migrations/20190629193445-make-root-page-public.js

@@ -9,7 +9,7 @@ const logger = loggerFactory('growi:migrate:make-root-page-public');
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = getPageModel();
     const Page = getPageModel();
 
 

+ 1 - 1
apps/app/src/migrations/20191102223900-drop-configs-indices.js

@@ -14,7 +14,7 @@ async function dropIndexIfExists(collection, indexName) {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const collection = db.collection('configs');
     const collection = db.collection('configs');
     await dropIndexIfExists(collection, 'ns_1');
     await dropIndexIfExists(collection, 'ns_1');

+ 1 - 1
apps/app/src/migrations/20191102223901-drop-pages-indices.js

@@ -21,7 +21,7 @@ async function dropIndexIfExists(db, collectionName, indexName) {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await dropIndexIfExists(db, 'pages', 'lastUpdateUser_1');
     await dropIndexIfExists(db, 'pages', 'lastUpdateUser_1');
     await dropIndexIfExists(db, 'pages', 'liker_1');
     await dropIndexIfExists(db, 'pages', 'liker_1');

+ 1 - 1
apps/app/src/migrations/20191126173016-adjust-pages-path.js

@@ -11,7 +11,7 @@ const logger = loggerFactory('growi:migrate:adjust-pages-path');
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = getPageModel();
     const Page = getPageModel();
 
 

+ 1 - 1
apps/app/src/migrations/20191127023815-drop-wrong-index-of-page-tag-relation.js

@@ -21,7 +21,7 @@ async function dropIndexIfExists(db, collectionName, indexName) {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await dropIndexIfExists(db, 'pagetagrelations', 'page_1_user_1');
     await dropIndexIfExists(db, 'pagetagrelations', 'page_1_user_1');
 
 

+ 1 - 1
apps/app/src/migrations/20200402160380-remove-deleteduser-from-relationgroup.js

@@ -11,7 +11,7 @@ const logger = loggerFactory('growi:migrate:remove-deleteduser-from-relationgrou
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const User = userModelFactory();
     const User = userModelFactory();
 
 

+ 1 - 1
apps/app/src/migrations/20200420160390-remove-crowi-layout.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:remove-crowi-lauout');
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const query = { key: 'customize:layout', value: JSON.stringify('crowi') };
     const query = { key: 'customize:layout', value: JSON.stringify('crowi') };
 
 

+ 2 - 2
apps/app/src/migrations/20200512005851-remove-behavior-type.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:remove-behavior-type');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.findOneAndDelete({ key: 'customize:behavior' }); // remove behavior
     await Config.findOneAndDelete({ key: 'customize:behavior' }); // remove behavior
 
 
@@ -20,7 +20,7 @@ module.exports = {
   async down(db, client) {
   async down(db, client) {
     // do not rollback
     // do not rollback
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const insertConfig = new Config({
     const insertConfig = new Config({
       ns: 'crowi',
       ns: 'crowi',

+ 1 - 1
apps/app/src/migrations/20200514001356-update-theme-color-for-dark.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:update-theme-color-for-dark');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Promise.all([
     await Promise.all([
       await Config.findOneAndUpdate({ key: 'customize:theme', value: JSON.stringify('default-dark') }, { value: JSON.stringify('default') }), // update default-dark
       await Config.findOneAndUpdate({ key: 'customize:theme', value: JSON.stringify('default-dark') }, { value: JSON.stringify('default') }), // update default-dark

+ 1 - 1
apps/app/src/migrations/20200620203632-normalize-locale-id.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:normalize-locale-id');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const User = userModelFactory();
     const User = userModelFactory();
 
 

+ 2 - 2
apps/app/src/migrations/20200827045151-remove-layout-setting.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:remove-layout-setting');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const layoutType = await Config.findOne({ key: 'customize:layout' });
     const layoutType = await Config.findOne({ key: 'customize:layout' });
 
 
@@ -39,7 +39,7 @@ module.exports = {
 
 
   async down(db, client) {
   async down(db, client) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const theme = await Config.findOne({ key: 'customize:theme' });
     const theme = await Config.findOne({ key: 'customize:theme' });
     const insertLayoutType = (theme.value === '"kibela"') ? 'kibela' : 'growi';
     const insertLayoutType = (theme.value === '"kibela"') ? 'kibela' : 'growi';

+ 2 - 2
apps/app/src/migrations/20200828024025-copy-aws-setting.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:remove-layout-setting');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const [accessKeyId, secretAccessKey] = await Promise.all([
     const [accessKeyId, secretAccessKey] = await Promise.all([
       Config.findOne({ key: 'aws:accessKeyId' }),
       Config.findOne({ key: 'aws:accessKeyId' }),
@@ -56,7 +56,7 @@ module.exports = {
 
 
   async down(db, client) {
   async down(db, client) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.deleteMany({ key: { $in: ['mail:sesAccessKeyId', 'mail:sesSecretAccessKey'] } });
     await Config.deleteMany({ key: { $in: ['mail:sesAccessKeyId', 'mail:sesSecretAccessKey'] } });
 
 

+ 2 - 2
apps/app/src/migrations/20200901034313-update-mail-transmission.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:update-mail-transmission');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const sesAccessKeyId = await Config.findOne({
     const sesAccessKeyId = await Config.findOne({
       ns: 'crowi',
       ns: 'crowi',
@@ -43,7 +43,7 @@ module.exports = {
 
 
   async down(db, client) {
   async down(db, client) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // remote 'mail:transmissionMethod'
     // remote 'mail:transmissionMethod'
     await Config.findOneAndDelete({
     await Config.findOneAndDelete({

+ 2 - 2
apps/app/src/migrations/20200903080025-remove-timeline-type.js.js

@@ -11,7 +11,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.findOneAndDelete({ key: 'customize:isEnabledTimeline' }); // remove timeline
     await Config.findOneAndDelete({ key: 'customize:isEnabledTimeline' }); // remove timeline
 
 
@@ -21,7 +21,7 @@ module.exports = {
   async down(db, client) {
   async down(db, client) {
     // do not rollback
     // do not rollback
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const insertConfig = new Config({
     const insertConfig = new Config({
       ns: 'crowi',
       ns: 'crowi',

+ 2 - 2
apps/app/src/migrations/20200915035234-rename-s3-config.js

@@ -34,7 +34,7 @@ const awsConfigs = [
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const request = awsConfigs.map((awsConfig) => {
     const request = awsConfigs.map((awsConfig) => {
       return {
       return {
@@ -53,7 +53,7 @@ module.exports = {
   async down(db, client) {
   async down(db, client) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
 
 
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const request = awsConfigs.map((awsConfig) => {
     const request = awsConfigs.map((awsConfig) => {
       return {
       return {

+ 1 - 1
apps/app/src/migrations/20210420160380-convert-double-to-date.js

@@ -9,7 +9,7 @@ const logger = loggerFactory('growi:migrate:remove-crowi-lauout');
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const Page = getModelSafely('Page') || getPageModel();
     const Page = getModelSafely('Page') || getPageModel();
 
 

+ 2 - 2
apps/app/src/migrations/20210830074539-update-configs-for-slackbot.js

@@ -17,7 +17,7 @@ const keyMap = {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     for await (const [oldKey, newKey] of Object.entries(keyMap)) {
     for await (const [oldKey, newKey] of Object.entries(keyMap)) {
       const isExist = (await Config.count({ key: newKey })) > 0;
       const isExist = (await Config.count({ key: newKey })) > 0;
@@ -37,7 +37,7 @@ module.exports = {
 
 
   async down(db) {
   async down(db) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     for await (const [oldKey, newKey] of Object.entries(keyMap)) {
     for await (const [oldKey, newKey] of Object.entries(keyMap)) {
       const isExist = (await Config.count({ key: oldKey })) > 0;
       const isExist = (await Config.count({ key: oldKey })) > 0;

+ 1 - 1
apps/app/src/migrations/20210906194521-slack-app-integration-set-default-value.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:slack-app-integration-set-default-va
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const SlackAppIntegration = slackAppIntegrationFactory();
     const SlackAppIntegration = slackAppIntegrationFactory();
 
 

+ 2 - 2
apps/app/src/migrations/20210921173042-add-is-trashed-field.js

@@ -21,7 +21,7 @@ const updateIsPageTrashed = async(db, updateIdList) => {
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const Page = getModelSafely('Page') || getPageModel();
     const Page = getModelSafely('Page') || getPageModel();
 
 
     let updateDeletedPageIds = [];
     let updateDeletedPageIds = [];
@@ -52,7 +52,7 @@ module.exports = {
 
 
   async down(db) {
   async down(db) {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     try {
     try {
       await db.collection('pagetagrelations').updateMany(
       await db.collection('pagetagrelations').updateMany(

+ 2 - 2
apps/app/src/migrations/20211005120030-slack-app-integration-rename-keys.js

@@ -8,7 +8,7 @@ const logger = loggerFactory('growi:migrate:slack-app-integration-rename-keys');
 
 
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const SlackAppIntegration = slackAppIntegrationFactory();
     const SlackAppIntegration = slackAppIntegrationFactory();
 
 
@@ -45,7 +45,7 @@ module.exports = {
   },
   },
 
 
   async down(db, next) {
   async down(db, next) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const SlackAppIntegration = slackAppIntegrationFactory();
     const SlackAppIntegration = slackAppIntegrationFactory();
 
 

+ 2 - 2
apps/app/src/migrations/20211005131430-config-without-proxy-command-permission-for-renaming.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:slack-app-integration-rename-keys');
 
 
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const isExist = (await Config.count({ key: 'slackbot:withoutProxy:commandPermission' })) > 0;
     const isExist = (await Config.count({ key: 'slackbot:withoutProxy:commandPermission' })) > 0;
     if (!isExist) return;
     if (!isExist) return;
@@ -53,7 +53,7 @@ module.exports = {
   },
   },
 
 
   async down(db, next) {
   async down(db, next) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const isExist = (await Config.count({ key: 'slackbot:withoutProxy:commandPermission' })) > 0;
     const isExist = (await Config.count({ key: 'slackbot:withoutProxy:commandPermission' })) > 0;
     if (!isExist) return next();
     if (!isExist) return next();

+ 2 - 2
apps/app/src/migrations/20211129125654-initialize-private-legacy-pages-named-query.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:initialize-private-legacy-pages-name
 
 
 module.exports = {
 module.exports = {
   async up(db, next) {
   async up(db, next) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     try {
     try {
       await NamedQuery.updateOne(
       await NamedQuery.updateOne(
@@ -29,7 +29,7 @@ module.exports = {
   },
   },
 
 
   async down(db, next) {
   async down(db, next) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     try {
     try {
       await NamedQuery.findOneAndDelete({
       await NamedQuery.findOneAndDelete({

+ 2 - 2
apps/app/src/migrations/20211227060705-revision-path-to-page-id-schema-migration--fixed-7549.js

@@ -17,7 +17,7 @@ const LIMIT = 300;
 module.exports = {
 module.exports = {
   // path => pageId
   // path => pageId
   async up(db, client) {
   async up(db, client) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const Page = getModelSafely('Page') || getPageModel();
     const Page = getModelSafely('Page') || getPageModel();
 
 
     const pagesStream = await Page.find({ revision: { $ne: null } }, { _id: 1, path: 1 }).cursor({ batch_size: LIMIT });
     const pagesStream = await Page.find({ revision: { $ne: null } }, { _id: 1, path: 1 }).cursor({ batch_size: LIMIT });
@@ -67,7 +67,7 @@ module.exports = {
 
 
   // pageId => path
   // pageId => path
   async down(db, client) {
   async down(db, client) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const Page = getModelSafely('Page') || getPageModel();
     const Page = getModelSafely('Page') || getPageModel();
 
 
     const pagesStream = await Page.find({ revision: { $ne: null } }, { _id: 1, path: 1 }).cursor({ batch_size: LIMIT });
     const pagesStream = await Page.find({ revision: { $ne: null } }, { _id: 1, path: 1 }).cursor({ batch_size: LIMIT });

+ 2 - 2
apps/app/src/migrations/20220131001218-convert-redirect-to-pages-to-page-redirect-documents.js

@@ -13,7 +13,7 @@ const BATCH_SIZE = 100;
 
 
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const pageCollection = await db.collection('pages');
     const pageCollection = await db.collection('pages');
     const PageRedirect = getModelSafely('PageRedirect') || PageRedirectModel;
     const PageRedirect = getModelSafely('PageRedirect') || PageRedirectModel;
 
 
@@ -49,7 +49,7 @@ module.exports = {
   },
   },
 
 
   async down(db, client) {
   async down(db, client) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const pageCollection = await db.collection('pages');
     const pageCollection = await db.collection('pages');
     const PageRedirect = getModelSafely('PageRedirect') || PageRedirectModel;
     const PageRedirect = getModelSafely('PageRedirect') || PageRedirectModel;
 
 

+ 1 - 1
apps/app/src/migrations/20220311011114-convert-page-delete-config.js

@@ -12,7 +12,7 @@ const logger = loggerFactory('growi:migrate:convert-page-delete-config');
 
 
 module.exports = {
 module.exports = {
   async up(db, client) {
   async up(db, client) {
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const isNewConfigExists = await Config.count({
     const isNewConfigExists = await Config.count({
       ns: 'crowi',
       ns: 'crowi',

+ 1 - 1
apps/app/src/migrations/20220411114257-set-sparse-option-to-slack-member-id.js

@@ -12,7 +12,7 @@ const logger = loggerFactory('growi:migrate:set-sparse-option-to-slack-member-id
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const User = userModelFactory();
     const User = userModelFactory();
     await User.syncIndexes();
     await User.syncIndexes();

+ 1 - 1
apps/app/src/migrations/20220613064207-add-attachment-type-to-existing-attachments.js

@@ -10,7 +10,7 @@ const logger = loggerFactory('growi:migrate:add-attachment-type-to-existing-atta
 module.exports = {
 module.exports = {
   async up(db) {
   async up(db) {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     // Add attachmentType for wiki page
     // Add attachmentType for wiki page
     // Filter pages where "attachmentType" doesn't exist and "page" is not null
     // Filter pages where "attachmentType" doesn't exist and "page" is not null

+ 2 - 2
apps/app/src/migrations/20221014130200-remove-customize-is-saved-states-of-tab-changes.js

@@ -11,7 +11,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up() {
   async up() {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.findOneAndDelete({ key: 'customize:isSavedStatesOfTabChanges' }); // remove isSavedStatesOfTabChanges
     await Config.findOneAndDelete({ key: 'customize:isSavedStatesOfTabChanges' }); // remove isSavedStatesOfTabChanges
 
 
@@ -20,7 +20,7 @@ module.exports = {
 
 
   async down() {
   async down() {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const insertConfig = new Config({
     const insertConfig = new Config({
       ns: 'crowi',
       ns: 'crowi',

+ 1 - 1
apps/app/src/migrations/20221219011829-remove-basic-auth-related-config.js

@@ -11,7 +11,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up() {
   async up() {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.findOneAndDelete({ key: 'security:passport-basic:isEnabled' });
     await Config.findOneAndDelete({ key: 'security:passport-basic:isEnabled' });
     await Config.findOneAndDelete({ key: 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser' });
     await Config.findOneAndDelete({ key: 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser' });

+ 2 - 2
apps/app/src/migrations/20230213090921-remove-presentation-configurations.js

@@ -11,7 +11,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up() {
   async up() {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakSeparator' });
     await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakSeparator' });
     await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakCustomSeparator' });
     await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakCustomSeparator' });
@@ -21,7 +21,7 @@ module.exports = {
 
 
   async down() {
   async down() {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const insertConfig = new Config({
     const insertConfig = new Config({
       ns: 'crowi',
       ns: 'crowi',

+ 2 - 2
apps/app/src/migrations/20230731075753-add_installed_date_to_config.js

@@ -10,7 +10,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up() {
   async up() {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
     const User = userModelFactory();
     const User = userModelFactory();
 
 
     const appInstalled = await Config.findOne({ key: 'app:installed' });
     const appInstalled = await Config.findOne({ key: 'app:installed' });
@@ -36,7 +36,7 @@ module.exports = {
 
 
   async down() {
   async down() {
     logger.info('Rollback migration');
     logger.info('Rollback migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     const appInstalled = await Config.findOne({ key: 'app:installed' });
     const appInstalled = await Config.findOne({ key: 'app:installed' });
     if (appInstalled != null) {
     if (appInstalled != null) {

+ 1 - 1
apps/app/src/migrations/20231102012742-clean-user-ui-settings-collection.js

@@ -11,7 +11,7 @@ const mongoose = require('mongoose');
 module.exports = {
 module.exports = {
   async up() {
   async up() {
     logger.info('Apply migration');
     logger.info('Apply migration');
-    mongoose.connect(getMongoUri(), mongoOptions);
+    await mongoose.connect(getMongoUri(), mongoOptions);
 
 
     await UserUISettings.updateMany(
     await UserUISettings.updateMany(
       {},
       {},

+ 1 - 1
apps/app/test/integration/global-setup.js

@@ -8,7 +8,7 @@ if (process.env.NODE_ENV !== 'test') {
 }
 }
 
 
 module.exports = async() => {
 module.exports = async() => {
-  mongoose.connect(getMongoUri(), mongoOptions);
+  await mongoose.connect(getMongoUri(), mongoOptions);
 
 
   // drop database
   // drop database
   await mongoose.connection.dropDatabase();
   await mongoose.connection.dropDatabase();