Browse Source

configure biome for app migrations files

Futa Arai 7 months ago
parent
commit
1a8f763670
44 changed files with 413 additions and 283 deletions
  1. 2 0
      apps/app/.eslintrc.js
  2. 3 3
      apps/app/src/linter-checker/test.js
  3. 3 2
      apps/app/src/migrations/19700101000000-foremost-1000-20241123211930-remove-index-for-ns-from-configs.js
  4. 3 2
      apps/app/src/migrations/19700101000000-foremost-1010-20250109000000-generate-service-instance-id.js
  5. 0 3
      apps/app/src/migrations/20180926134048-make-email-unique.js
  6. 13 9
      apps/app/src/migrations/20180927102719-init-serverurl.js
  7. 12 7
      apps/app/src/migrations/20181019114028-abolish-page-group-relation.js
  8. 3 2
      apps/app/src/migrations/20190618104011-add-config-app-installed.js
  9. 4 7
      apps/app/src/migrations/20190619055421-adjust-page-grant.js
  10. 0 2
      apps/app/src/migrations/20190624110950-fill-last-update-user.js
  11. 3 1
      apps/app/src/migrations/20191102223901-drop-pages-indices.js
  12. 0 2
      apps/app/src/migrations/20191126173016-adjust-pages-path.js
  13. 6 2
      apps/app/src/migrations/20191127023815-drop-wrong-index-of-page-tag-relation.js
  14. 6 4
      apps/app/src/migrations/20200402160380-remove-deleteduser-from-relationgroup.js
  15. 8 2
      apps/app/src/migrations/20200514001356-update-theme-color-for-dark.js
  16. 2 8
      apps/app/src/migrations/20200620203632-normalize-locale-id.js
  17. 1 1
      apps/app/src/migrations/20200827045151-remove-layout-setting.js
  18. 3 1
      apps/app/src/migrations/20200828024025-copy-aws-setting.js
  19. 10 6
      apps/app/src/migrations/20200901034313-update-mail-transmission.js
  20. 0 1
      apps/app/src/migrations/20200903080025-remove-timeline-type.js.js
  21. 2 3
      apps/app/src/migrations/20200915035234-rename-s3-config.js
  22. 5 2
      apps/app/src/migrations/20210420160380-convert-double-to-date.js
  23. 8 4
      apps/app/src/migrations/20210906194521-slack-app-integration-set-default-value.js
  24. 7 3
      apps/app/src/migrations/20210913153942-migrate-slack-app-integration-schema.js
  25. 22 19
      apps/app/src/migrations/20210921173042-add-is-trashed-field.js
  26. 12 5
      apps/app/src/migrations/20211005120030-slack-app-integration-rename-keys.js
  27. 22 7
      apps/app/src/migrations/20211005131430-config-without-proxy-command-permission-for-renaming.js
  28. 19 10
      apps/app/src/migrations/20211129125654-initialize-private-legacy-pages-named-query.js
  29. 19 16
      apps/app/src/migrations/20211227060705-revision-path-to-page-id-schema-migration--fixed-7549.js
  30. 16 8
      apps/app/src/migrations/20220131001218-convert-redirect-to-pages-to-page-redirect-documents.js
  31. 21 24
      apps/app/src/migrations/20220311011114-convert-page-delete-config.js
  32. 3 1
      apps/app/src/migrations/20220411114257-set-sparse-option-to-slack-member-id.js
  33. 15 13
      apps/app/src/migrations/20220613064207-add-attachment-type-to-existing-attachments.js
  34. 3 2
      apps/app/src/migrations/20221014130200-remove-customize-is-saved-states-of-tab-changes.js
  35. 3 2
      apps/app/src/migrations/20221219011829-remove-basic-auth-related-config.js
  36. 9 4
      apps/app/src/migrations/20230213090921-remove-presentation-configurations.js
  37. 51 42
      apps/app/src/migrations/20230723061824-granted-group-to-array-of-objects.js
  38. 18 11
      apps/app/src/migrations/20230731075753-add_installed_date_to_config.js
  39. 0 1
      apps/app/src/migrations/20231102012742-clean-user-ui-settings-collection.js
  40. 6 9
      apps/app/src/migrations/20231223155127-non-null-granted-groups.js
  41. 9 10
      apps/app/src/migrations/20240924181317-changed-status-in-inappnotifications-from-unread-to-unopened.js
  42. 19 12
      apps/app/src/migrations/20241107172359-rename-pageId-to-page.js
  43. 30 9
      apps/app/src/migrations/20250522105040-delete-old-index-for-vector-store-file-relation.js
  44. 12 1
      biome.json

+ 2 - 0
apps/app/.eslintrc.js

@@ -28,6 +28,8 @@ module.exports = {
     'test/integration/setup.js',
     'bin/**',
     'config/**',
+    'src/linter-checker/**',
+    'src/migrations/**',
   ],
   settings: {
     // resolve path aliases by eslint-import-resolver-typescript

+ 3 - 3
apps/app/src/linter-checker/test.js

@@ -2,7 +2,7 @@
  * VSCode の Eslint 設定チェック方法
  *
  * 1. .eslilntignore ファイル中の `/src/linter-checker/**` 行を消す
- * 
+ *
  * 2. VSCode で以下のエラーが表示されていることを確認
  *   - constructor で eslint(space-before-blocks)
  *   - ファイル末尾の ";" で eslint(eol-last)
@@ -15,9 +15,9 @@
  *
  */
 class EslintTest {
-  constructor(){
+  constructor() {
     this.i = 0;
   }
 }
 
-module.exports = EslintTest;
+module.exports = EslintTest;

+ 3 - 2
apps/app/src/migrations/19700101000000-foremost-1000-20241123211930-remove-index-for-ns-from-configs.js

@@ -3,12 +3,13 @@ import mongoose from 'mongoose';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:remove-index-for-ns-from-configs');
 
 async function dropIndexIfExists(db, collectionName, indexName) {
   // check existence of the collection
-  const items = await db.listCollections({ name: collectionName }, { nameOnly: true }).toArray();
+  const items = await db
+    .listCollections({ name: collectionName }, { nameOnly: true })
+    .toArray();
   if (items.length === 0) {
     return;
   }

+ 3 - 2
apps/app/src/migrations/19700101000000-foremost-1010-20250109000000-generate-service-instance-id.js

@@ -5,7 +5,6 @@ import { configManager } from '~/server/service/config-manager';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:generate-service-instance-id');
 
 module.exports = {
@@ -15,7 +14,9 @@ module.exports = {
 
     await configManager.loadConfigs();
 
-    await configManager.updateConfig('app:serviceInstanceId', uuidv4(), { skipPubsub: true });
+    await configManager.updateConfig('app:serviceInstanceId', uuidv4(), {
+      skipPubsub: true,
+    });
   },
 
   async down() {

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

@@ -4,11 +4,9 @@ import userModelFactory from '~/server/models/user';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:make-email-unique');
 
 module.exports = {
-
   async up(db, next) {
     logger.info('Start migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
@@ -44,5 +42,4 @@ module.exports = {
     // do not rollback
     next();
   },
-
 };

+ 13 - 9
apps/app/src/migrations/20180927102719-init-serverurl.js

@@ -12,12 +12,11 @@ const logger = loggerFactory('growi:migrate:init-serverurl');
  */
 function isAllValuesSame(array) {
   return !!array.reduce((a, b) => {
-    return (a === b) ? a : NaN;
+    return a === b ? a : NaN;
   });
 }
 
 module.exports = {
-
   async up(db) {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
@@ -28,7 +27,9 @@ module.exports = {
     });
     // exit if exists
     if (siteUrlConfig != null) {
-      logger.info('\'app:siteUrl\' is already exists. This migration terminates without any changes.');
+      logger.info(
+        "'app:siteUrl' is already exists. This migration terminates without any changes.",
+      );
       return;
     }
 
@@ -48,11 +49,15 @@ module.exports = {
       logger.info(configs);
 
       // extract domain
-      const siteUrls = configs.map((config) => {
-        // see https://regex101.com/r/Q0Isjo/2
-        const match = config.value.match(/^"(https?:\/\/[^/]+).*"$/);
-        return (match != null) ? match[1] : null;
-      }).filter((value) => { return value != null });
+      const siteUrls = configs
+        .map((config) => {
+          // see https://regex101.com/r/Q0Isjo/2
+          const match = config.value.match(/^"(https?:\/\/[^/]+).*"$/);
+          return match != null ? match[1] : null;
+        })
+        .filter((value) => {
+          return value != null;
+        });
 
       // determine serverUrl if all values are same
       if (siteUrls.length > 0 && isAllValuesSame(siteUrls)) {
@@ -82,5 +87,4 @@ module.exports = {
 
     logger.info('Migration has been successfully rollbacked');
   },
-
 };

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

@@ -5,11 +5,12 @@ import userGroupModelFactory from '~/server/models/user-group';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:abolish-page-group-relation');
 
 async function isCollectionExists(db, collectionName) {
-  const collections = await db.listCollections({ name: collectionName }).toArray();
+  const collections = await db
+    .listCollections({ name: collectionName })
+    .toArray();
   return collections.length > 0;
 }
 
@@ -28,14 +29,16 @@ async function isCollectionExists(db, collectionName) {
  *   - Page model has 'grantedGroup' field newly
  */
 module.exports = {
-
   async up(db) {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
 
-    const isPagegrouprelationsExists = await isCollectionExists(db, 'pagegrouprelations');
+    const isPagegrouprelationsExists = await isCollectionExists(
+      db,
+      'pagegrouprelations',
+    );
     if (!isPagegrouprelationsExists) {
-      logger.info("'pagegrouprelations' collection doesn't exist");   // eslint-disable-line
+      logger.info("'pagegrouprelations' collection doesn't exist"); // eslint-disable-line
       logger.info('Migration has successfully applied');
       return;
     }
@@ -44,7 +47,10 @@ module.exports = {
     const UserGroup = userGroupModelFactory();
 
     // retrieve all documents from 'pagegrouprelations'
-    const relations = await db.collection('pagegrouprelations').find().toArray();
+    const relations = await db
+      .collection('pagegrouprelations')
+      .find()
+      .toArray();
 
     /* eslint-disable no-await-in-loop */
     for (const relation of relations) {
@@ -115,5 +121,4 @@ module.exports = {
 
     logger.info('Migration has been successfully rollbacked');
   },
-
 };

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

@@ -16,7 +16,6 @@ const logger = loggerFactory('growi:migrate:add-config-app-installed');
  *     - value will be false if no users exist
  */
 module.exports = {
-
   async up(db) {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
@@ -29,7 +28,9 @@ module.exports = {
     });
     // exit if exists
     if (appInstalled != null) {
-      logger.info('\'app:appInstalled\' is already exists. This migration terminates without any changes.');
+      logger.info(
+        "'app:appInstalled' is already exists. This migration terminates without any changes.",
+      );
       return;
     }
 

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

@@ -7,7 +7,6 @@ import loggerFactory from '~/utils/logger';
 const logger = loggerFactory('growi:migrate:adjust-page-grant');
 
 module.exports = {
-
   async up(db) {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
@@ -16,16 +15,14 @@ module.exports = {
 
     await Page.bulkWrite([
       {
-        updateMany:
-         {
-           filter: { grant: null },
-           update: { $set: { grant: Page.GRANT_PUBLIC } },
-         },
+        updateMany: {
+          filter: { grant: null },
+          update: { $set: { grant: Page.GRANT_PUBLIC } },
+        },
       },
     ]);
 
     logger.info('Migration has successfully applied');
-
   },
 
   down(db) {

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

@@ -10,7 +10,6 @@ const logger = loggerFactory('growi:migrate:abolish-page-group-relation');
  * FIX https://github.com/weseek/growi/issues/1067
  */
 module.exports = {
-
   async up(db) {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
@@ -47,5 +46,4 @@ module.exports = {
   down(db) {
     // do not rollback
   },
-
 };

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

@@ -7,7 +7,9 @@ const logger = loggerFactory('growi:migrate:drop-pages-indices');
 
 async function dropIndexIfExists(db, collectionName, indexName) {
   // check existence of the collection
-  const items = await db.listCollections({ name: collectionName }, { nameOnly: true }).toArray();
+  const items = await db
+    .listCollections({ name: collectionName }, { nameOnly: true })
+    .toArray();
   if (items.length === 0) {
     return;
   }

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

@@ -7,7 +7,6 @@ import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:migrate:adjust-pages-path');
 
-
 module.exports = {
   async up(db) {
     logger.info('Apply migration');
@@ -18,7 +17,6 @@ module.exports = {
     // retrieve target data
     const pages = await Page.find({ path: /^(?!\/)/ });
 
-
     // create requests for bulkWrite
     const requests = pages.map((page) => {
       const adjustedPath = addHeadingSlash(page.path);

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

@@ -3,11 +3,15 @@ import mongoose from 'mongoose';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:migrate:drop-wrong-index-of-page-tag-relation');
+const logger = loggerFactory(
+  'growi:migrate:drop-wrong-index-of-page-tag-relation',
+);
 
 async function dropIndexIfExists(db, collectionName, indexName) {
   // check existence of the collection
-  const items = await db.listCollections({ name: collectionName }, { nameOnly: true }).toArray();
+  const items = await db
+    .listCollections({ name: collectionName }, { nameOnly: true })
+    .toArray();
   if (items.length === 0) {
     return;
   }

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

@@ -5,8 +5,9 @@ import UserGroupRelation from '~/server/models/user-group-relation';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:remove-deleteduser-from-relationgroup');
+const logger = loggerFactory(
+  'growi:migrate:remove-deleteduser-from-relationgroup',
+);
 
 module.exports = {
   async up(db) {
@@ -16,13 +17,14 @@ module.exports = {
     const User = userModelFactory();
 
     const deletedUsers = await User.find({ status: 4 }); // deleted user
-    const requests = await UserGroupRelation.remove({ relatedUser: deletedUsers });
+    const requests = await UserGroupRelation.remove({
+      relatedUser: deletedUsers,
+    });
 
     if (requests.size === 0) {
       return logger.info('This migration terminates without any changes.');
     }
     logger.info('Migration has successfully applied');
-
   },
 
   down(db, next) {

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

@@ -13,8 +13,14 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     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('blue-night') }, { value: JSON.stringify('mono-blue') }), // update blue-night
+      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('blue-night') },
+        { value: JSON.stringify('mono-blue') },
+      ), // update blue-night
     ]);
 
     logger.info('Migration has successfully applied');

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

@@ -27,15 +27,9 @@ module.exports = {
       ),
 
       // update en-US -> en_US
-      User.updateMany(
-        { lang: 'en-US' },
-        { lang: 'en_US' },
-      ),
+      User.updateMany({ lang: 'en-US' }, { lang: 'en_US' }),
       // update ja -> ja_JP
-      User.updateMany(
-        { lang: 'ja' },
-        { lang: 'ja_JP' },
-      ),
+      User.updateMany({ lang: 'ja' }, { lang: 'ja_JP' }),
     ]);
 
     logger.info('Migration has successfully applied');

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

@@ -42,7 +42,7 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     const theme = await Config.findOne({ key: 'customize:theme' });
-    const insertLayoutType = (theme.value === '"kibela"') ? 'kibela' : 'growi';
+    const insertLayoutType = theme.value === '"kibela"' ? 'kibela' : 'growi';
 
     const insertConfig = new Config({
       key: 'customize:layout',

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

@@ -56,7 +56,9 @@ module.exports = {
     logger.info('Rollback migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
 
-    await Config.deleteMany({ key: { $in: ['mail:sesAccessKeyId', 'mail:sesSecretAccessKey'] } });
+    await Config.deleteMany({
+      key: { $in: ['mail:sesAccessKeyId', 'mail:sesSecretAccessKey'] },
+    });
 
     logger.info('Migration has been successfully rollbacked');
   },

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

@@ -20,15 +20,20 @@ module.exports = {
     });
 
     if (sesAccessKeyId == null) {
-      return logger.info('The key \'mail:sesAccessKeyId\' does not exist, value of transmission method will be set smtp automatically.');
+      return logger.info(
+        "The key 'mail:sesAccessKeyId' does not exist, value of transmission method will be set smtp automatically.",
+      );
     }
     if (transmissionMethod != null) {
-      return logger.info('The key \'mail:transmissionMethod\' already exists, there is no need to migrate.');
+      return logger.info(
+        "The key 'mail:transmissionMethod' already exists, there is no need to migrate.",
+      );
     }
 
-    const value = sesAccessKeyId.value != null
-      ? JSON.stringify('ses')
-      : JSON.stringify('smtp');
+    const value =
+      sesAccessKeyId.value != null
+        ? JSON.stringify('ses')
+        : JSON.stringify('smtp');
 
     await Config.create({
       ns: 'crowi',
@@ -36,7 +41,6 @@ module.exports = {
       value,
     });
     logger.info('Migration has successfully applied');
-
   },
 
   async down(db, client) {

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

@@ -3,7 +3,6 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:remove-timeline-type');
 
 const mongoose = require('mongoose');

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

@@ -3,7 +3,6 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:remove-timeline-type');
 
 const mongoose = require('mongoose');
@@ -40,7 +39,7 @@ module.exports = {
       return {
         updateOne: {
           filter: { key: awsConfig.oldValue },
-          update:  { key: awsConfig.newValue },
+          update: { key: awsConfig.newValue },
         },
       };
     });
@@ -59,7 +58,7 @@ module.exports = {
       return {
         updateOne: {
           filter: { key: awsConfig.newValue },
-          update:  { key: awsConfig.oldValue },
+          update: { key: awsConfig.oldValue },
         },
       };
     });

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

@@ -1,7 +1,11 @@
 import mongoose from 'mongoose';
 
 import getPageModel from '~/server/models/page';
-import { getModelSafely, getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
+import {
+  getModelSafely,
+  getMongoUri,
+  mongoOptions,
+} from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:migrate:remove-crowi-lauout');
@@ -31,7 +35,6 @@ module.exports = {
     await Page.bulkWrite(operations);
 
     logger.info('Migration has successfully applied');
-
   },
 
   down(db) {

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

@@ -4,8 +4,9 @@ import slackAppIntegrationFactory from '~/server/models/slack-app-integration';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:slack-app-integration-set-default-value');
+const logger = loggerFactory(
+  'growi:migrate:slack-app-integration-set-default-value',
+);
 
 module.exports = {
   async up(db) {
@@ -16,8 +17,11 @@ module.exports = {
 
     // Add togetter command if supportedCommandsForBroadcastUse already exists
     const slackAppIntegrations = await SlackAppIntegration.find();
-    slackAppIntegrations.forEach(async(doc) => {
-      if (doc.supportedCommandsForSingleUse != null && !doc.supportedCommandsForSingleUse.includes('togetter')) {
+    slackAppIntegrations.forEach(async (doc) => {
+      if (
+        doc.supportedCommandsForSingleUse != null &&
+        !doc.supportedCommandsForSingleUse.includes('togetter')
+      ) {
         doc.supportedCommandsForSingleUse.push('togetter');
       }
       await doc.save();

+ 7 - 3
apps/app/src/migrations/20210913153942-migrate-slack-app-integration-schema.js

@@ -1,12 +1,16 @@
-import { defaultSupportedCommandsNameForBroadcastUse, defaultSupportedCommandsNameForSingleUse } from '@growi/slack';
+import {
+  defaultSupportedCommandsNameForBroadcastUse,
+  defaultSupportedCommandsNameForSingleUse,
+} from '@growi/slack';
 import mongoose from 'mongoose';
 
 import slackAppIntegrationFactory from '~/server/models/slack-app-integration';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:migrate-slack-app-integration-schema');
+const logger = loggerFactory(
+  'growi:migrate:migrate-slack-app-integration-schema',
+);
 
 // create default data
 const defaultDataForBroadcastUse = {};

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

@@ -1,7 +1,11 @@
 import mongoose from 'mongoose';
 
 import getPageModel from '~/server/models/page';
-import { getModelSafely, getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
+import {
+  getModelSafely,
+  getMongoUri,
+  mongoOptions,
+} from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:migrate:add-column-is-trashed');
@@ -11,11 +15,13 @@ const LIMIT = 1000;
 /**
  * set isPageTrashed of pagetagrelations included in updateIdList as true
  */
-const updateIsPageTrashed = async(db, updateIdList) => {
-  await db.collection('pagetagrelations').updateMany(
-    { relatedPage: { $in: updateIdList } },
-    { $set: { isPageTrashed: true } },
-  );
+const updateIsPageTrashed = async (db, updateIdList) => {
+  await db
+    .collection('pagetagrelations')
+    .updateMany(
+      { relatedPage: { $in: updateIdList } },
+      { $set: { isPageTrashed: true } },
+    );
 };
 
 module.exports = {
@@ -27,12 +33,13 @@ module.exports = {
     let updateDeletedPageIds = [];
 
     // set isPageTrashed as false temporarily
-    await db.collection('pagetagrelations').updateMany(
-      {},
-      { $set: { isPageTrashed: false } },
-    );
+    await db
+      .collection('pagetagrelations')
+      .updateMany({}, { $set: { isPageTrashed: false } });
 
-    for await (const deletedPage of Page.find({ status: Page.STATUS_DELETED }).select('_id').cursor()) {
+    for await (const deletedPage of Page.find({ status: Page.STATUS_DELETED })
+      .select('_id')
+      .cursor()) {
       updateDeletedPageIds.push(deletedPage._id);
       // excute updateMany by one thousand ids
       if (updateDeletedPageIds.length === LIMIT) {
@@ -47,7 +54,6 @@ module.exports = {
     }
 
     logger.info('Migration has successfully applied');
-
   },
 
   async down(db) {
@@ -55,16 +61,13 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     try {
-      await db.collection('pagetagrelations').updateMany(
-        {},
-        { $unset: { isPageTrashed: '' } },
-      );
+      await db
+        .collection('pagetagrelations')
+        .updateMany({}, { $unset: { isPageTrashed: '' } });
       logger.info('Migration has been successfully rollbacked');
-    }
-    catch (err) {
+    } catch (err) {
       logger.error(err);
       logger.info('Migration has failed');
     }
-
   },
 };

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

@@ -18,9 +18,13 @@ module.exports = {
 
     // create operations
     const operations = slackAppIntegrations.map((doc) => {
-      const permissionsForSingleUseCommands = doc._doc.permissionsForSingleUseCommands;
+      const permissionsForSingleUseCommands =
+        doc._doc.permissionsForSingleUseCommands;
       const createValue = permissionsForSingleUseCommands.get('create', false);
-      const togetterValue = permissionsForSingleUseCommands.get('togetter', false);
+      const togetterValue = permissionsForSingleUseCommands.get(
+        'togetter',
+        false,
+      );
 
       const newPermissionsForSingleUseCommands = {
         note: createValue,
@@ -32,7 +36,8 @@ module.exports = {
           filter: { _id: doc._id },
           update: {
             $set: {
-              permissionsForSingleUseCommands: newPermissionsForSingleUseCommands,
+              permissionsForSingleUseCommands:
+                newPermissionsForSingleUseCommands,
             },
           },
         },
@@ -55,7 +60,8 @@ module.exports = {
 
     // create operations
     const operations = slackAppIntegrations.map((doc) => {
-      const permissionsForSingleUseCommands = doc._doc.permissionsForSingleUseCommands;
+      const permissionsForSingleUseCommands =
+        doc._doc.permissionsForSingleUseCommands;
       const noteValue = permissionsForSingleUseCommands.get('note', false);
       const keepValue = permissionsForSingleUseCommands.get('keep', false);
 
@@ -69,7 +75,8 @@ module.exports = {
           filter: { _id: doc._id },
           update: {
             $set: {
-              permissionsForSingleUseCommands: newPermissionsForSingleUseCommands,
+              permissionsForSingleUseCommands:
+                newPermissionsForSingleUseCommands,
             },
           },
         },

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

@@ -5,19 +5,26 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:slack-app-integration-rename-keys');
 
 module.exports = {
   async up(db) {
     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;
 
-    const commandPermissionValue = await Config.findOne({ key: 'slackbot:withoutProxy:commandPermission' });
+    const commandPermissionValue = await Config.findOne({
+      key: 'slackbot:withoutProxy:commandPermission',
+    });
     // do nothing if data is 'null' or null
-    if (commandPermissionValue._doc.value === 'null' || commandPermissionValue._doc.value == null) return;
+    if (
+      commandPermissionValue._doc.value === 'null' ||
+      commandPermissionValue._doc.value == null
+    )
+      return;
 
     const commandPermission = JSON.parse(commandPermissionValue._doc.value);
 
@@ -55,12 +62,20 @@ module.exports = {
   async down(db, next) {
     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();
 
-    const commandPermissionValue = await Config.findOne({ key: 'slackbot:withoutProxy:commandPermission' });
+    const commandPermissionValue = await Config.findOne({
+      key: 'slackbot:withoutProxy:commandPermission',
+    });
     // do nothing if data is 'null' or null
-    if (commandPermissionValue._doc.value === 'null' || commandPermissionValue._doc.value == null) return next();
+    if (
+      commandPermissionValue._doc.value === 'null' ||
+      commandPermissionValue._doc.value == null
+    )
+      return next();
 
     const commandPermission = JSON.parse(commandPermissionValue._doc.value);
 

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

@@ -5,8 +5,9 @@ import NamedQuery from '~/server/models/named-query';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:initialize-private-legacy-pages-named-query');
+const logger = loggerFactory(
+  'growi:migrate:initialize-private-legacy-pages-named-query',
+);
 
 module.exports = {
   async up(db, next) {
@@ -18,14 +19,18 @@ module.exports = {
         { delegatorName: SearchDelegatorName.PRIVATE_LEGACY_PAGES },
         { upsert: true },
       );
-    }
-    catch (err) {
-      logger.error('Failed to migrate named query for private legacy pages search delagator.', err);
+    } catch (err) {
+      logger.error(
+        'Failed to migrate named query for private legacy pages search delagator.',
+        err,
+      );
       throw err;
     }
 
     next();
-    logger.info('Successfully migrated named query for private legacy pages search delagator.');
+    logger.info(
+      'Successfully migrated named query for private legacy pages search delagator.',
+    );
   },
 
   async down(db, next) {
@@ -36,13 +41,17 @@ module.exports = {
         name: SearchDelegatorName.PRIVATE_LEGACY_PAGES,
         delegatorName: SearchDelegatorName.PRIVATE_LEGACY_PAGES,
       });
-    }
-    catch (err) {
-      logger.error('Failed to delete named query for private legacy pages search delagator.', err);
+    } catch (err) {
+      logger.error(
+        'Failed to delete named query for private legacy pages search delagator.',
+        err,
+      );
       throw err;
     }
 
     next();
-    logger.info('Successfully deleted named query for private legacy pages search delagator.');
+    logger.info(
+      'Successfully deleted named query for private legacy pages search delagator.',
+    );
   },
 };

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

@@ -1,16 +1,20 @@
+import mongoose from 'mongoose';
 import { Writable } from 'stream';
 import { pipeline } from 'stream/promises';
 
-import mongoose from 'mongoose';
-
 import getPageModel from '~/server/models/page';
 import { Revision } from '~/server/models/revision';
 import { createBatchStream } from '~/server/util/batch-stream';
-import { getModelSafely, getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
+import {
+  getModelSafely,
+  getMongoUri,
+  mongoOptions,
+} from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:revision-path-to-page-id-schema-migration--fixed-7549');
+const logger = loggerFactory(
+  'growi:migrate:revision-path-to-page-id-schema-migration--fixed-7549',
+);
 
 const LIMIT = 300;
 
@@ -20,7 +24,10 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
     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 });
     const batchStrem = createBatchStream(LIMIT);
 
     const migratePagesStream = new Writable({
@@ -30,10 +37,7 @@ module.exports = {
           return {
             updateMany: {
               filter: {
-                $and: [
-                  { path: page.path },
-                  { pageId: { $exists: false } },
-                ],
+                $and: [{ path: page.path }, { pageId: { $exists: false } }],
               },
               update: [
                 {
@@ -66,7 +70,10 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
     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 });
     const batchStrem = createBatchStream(LIMIT);
 
     const migratePagesStream = new Writable({
@@ -76,11 +83,7 @@ module.exports = {
           return {
             updateMany: {
               filter: {
-                $and: [
-                  { pageId: page._id },
-                  { path: { $exists: false } },
-                ],
-
+                $and: [{ pageId: page._id }, { path: { $exists: false } }],
               },
               update: [
                 {

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

@@ -3,21 +3,31 @@ import mongoose from 'mongoose';
 // eslint-disable-next-line import/no-named-as-default
 import PageRedirectModel from '~/server/models/page-redirect';
 import { createBatchStream } from '~/server/util/batch-stream';
-import { getModelSafely, getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
+import {
+  getModelSafely,
+  getMongoUri,
+  mongoOptions,
+} from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:migrate:convert-redirect-to-pages-to-page-redirect-documents');
+const logger = loggerFactory(
+  'growi:migrate:convert-redirect-to-pages-to-page-redirect-documents',
+);
 
 const BATCH_SIZE = 100;
 
-
 module.exports = {
   async up(db, client) {
     await mongoose.connect(getMongoUri(), mongoOptions);
     const pageCollection = await db.collection('pages');
     const PageRedirect = getModelSafely('PageRedirect') || PageRedirectModel;
 
-    const cursor = pageCollection.find({ redirectTo: { $exists: true, $ne: null } }, { path: 1, redirectTo: 1, _id: 0 }).stream();
+    const cursor = pageCollection
+      .find(
+        { redirectTo: { $exists: true, $ne: null } },
+        { path: 1, redirectTo: 1, _id: 0 },
+      )
+      .stream();
     const batchStream = createBatchStream(BATCH_SIZE);
 
     // redirectTo => PageRedirect
@@ -35,8 +45,7 @@ module.exports = {
 
       try {
         await PageRedirect.bulkWrite(insertPageRedirectOperations);
-      }
-      catch (err) {
+      } catch (err) {
         if (err.code !== 11000) {
           throw Error(`Failed to migrate: ${err}`);
         }
@@ -71,8 +80,7 @@ module.exports = {
 
       try {
         await pageCollection.bulkWrite(insertPageOperations);
-      }
-      catch (err) {
+      } catch (err) {
         if (err.code !== 11000) {
           throw Error(`Failed to migrate: ${err}`);
         }

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

@@ -1,7 +1,8 @@
 import mongoose from 'mongoose';
 
 import {
-  PageRecursiveDeleteConfigValue, PageRecursiveDeleteCompConfigValue,
+  PageRecursiveDeleteCompConfigValue,
+  PageRecursiveDeleteConfigValue,
 } from '~/interfaces/page-delete-config';
 import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
@@ -9,14 +10,14 @@ import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:migrate:convert-page-delete-config');
 
-
 module.exports = {
   async up(db, client) {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
-    const isNewConfigExists = await Config.count({
-      key: 'security:pageDeletionAuthority',
-    }) > 0;
+    const isNewConfigExists =
+      (await Config.count({
+        key: 'security:pageDeletionAuthority',
+      })) > 0;
 
     if (isNewConfigExists) {
       logger.info('This migration is skipped because new configs are existed.');
@@ -31,25 +32,21 @@ module.exports = {
     const oldValue = oldConfig?.value ?? '"anyOne"';
 
     try {
-
-      await Config.insertMany(
-        [
-          {
-            key: 'security:pageDeletionAuthority',
-            value: oldValue,
-          },
-          {
-            key: 'security:pageRecursiveDeletionAuthority',
-            value: `"${PageRecursiveDeleteConfigValue.Inherit}"`,
-          },
-          {
-            key: 'security:pageRecursiveCompleteDeletionAuthority',
-            value: `"${PageRecursiveDeleteCompConfigValue.Inherit}"`,
-          },
-        ],
-      );
-    }
-    catch (err) {
+      await Config.insertMany([
+        {
+          key: 'security:pageDeletionAuthority',
+          value: oldValue,
+        },
+        {
+          key: 'security:pageRecursiveDeletionAuthority',
+          value: `"${PageRecursiveDeleteConfigValue.Inherit}"`,
+        },
+        {
+          key: 'security:pageRecursiveCompleteDeletionAuthority',
+          value: `"${PageRecursiveDeleteCompConfigValue.Inherit}"`,
+        },
+      ]);
+    } catch (err) {
       logger.error('Failed to migrate page delete configs', err);
       throw err;
     }

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

@@ -4,7 +4,9 @@ import userModelFactory from '~/server/models/user';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:migrate:set-sparse-option-to-slack-member-id');
+const logger = loggerFactory(
+  'growi:migrate:set-sparse-option-to-slack-member-id',
+);
 
 /**
  * set sparse option to slackMemberId

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

@@ -5,7 +5,9 @@ import { Attachment } from '~/server/models/attachment';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:migrate:add-attachment-type-to-existing-attachments');
+const logger = loggerFactory(
+  'growi:migrate:add-attachment-type-to-existing-attachments',
+);
 
 module.exports = {
   async up(db) {
@@ -15,26 +17,26 @@ module.exports = {
     // Add attachmentType for wiki page
     // Filter pages where "attachmentType" doesn't exist and "page" is not null
     const operationsForWikiPage = {
-      updateMany:
-         {
-           filter: { page: { $ne: null }, attachmentType: { $exists: false } },
-           update: { $set: { attachmentType: AttachmentType.WIKI_PAGE } },
-         },
+      updateMany: {
+        filter: { page: { $ne: null }, attachmentType: { $exists: false } },
+        update: { $set: { attachmentType: AttachmentType.WIKI_PAGE } },
+      },
     };
 
     // Add attachmentType for profile image
     // Filter pages where "attachmentType" doesn't exist and "page" is null
     const operationsForProfileImage = {
-      updateMany:
-        {
-          filter: { page: { $eq: null }, attachmentType: { $exists: false } },
-          update: { $set: { attachmentType: AttachmentType.PROFILE_IMAGE } },
-        },
+      updateMany: {
+        filter: { page: { $eq: null }, attachmentType: { $exists: false } },
+        update: { $set: { attachmentType: AttachmentType.PROFILE_IMAGE } },
+      },
     };
-    await Attachment.bulkWrite([operationsForWikiPage, operationsForProfileImage]);
+    await Attachment.bulkWrite([
+      operationsForWikiPage,
+      operationsForProfileImage,
+    ]);
 
     logger.info('Migration has successfully applied');
-
   },
 
   async down(db) {

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

@@ -3,7 +3,6 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:remove-isSavedStatesOfTabChanges');
 
 const mongoose = require('mongoose');
@@ -13,7 +12,9 @@ module.exports = {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
 
-    await Config.findOneAndDelete({ key: 'customize:isSavedStatesOfTabChanges' }); // remove isSavedStatesOfTabChanges
+    await Config.findOneAndDelete({
+      key: 'customize:isSavedStatesOfTabChanges',
+    }); // remove isSavedStatesOfTabChanges
 
     logger.info('Migration has successfully applied');
   },

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

@@ -3,7 +3,6 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:remove-basic-auth-related-config');
 
 const mongoose = require('mongoose');
@@ -14,7 +13,9 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     await Config.findOneAndDelete({ key: 'security:passport-basic:isEnabled' });
-    await Config.findOneAndDelete({ key: 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser' });
+    await Config.findOneAndDelete({
+      key: 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser',
+    });
 
     logger.info('Migration has successfully applied');
   },

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

@@ -3,8 +3,9 @@ import { Config } from '~/server/models/config';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
-const logger = loggerFactory('growi:migrate:remove-presentation-configurations');
+const logger = loggerFactory(
+  'growi:migrate:remove-presentation-configurations',
+);
 
 const mongoose = require('mongoose');
 
@@ -13,8 +14,12 @@ module.exports = {
     logger.info('Apply migration');
     await mongoose.connect(getMongoUri(), mongoOptions);
 
-    await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakSeparator' });
-    await Config.findOneAndDelete({ key: 'markdown:presentation:pageBreakCustomSeparator' });
+    await Config.findOneAndDelete({
+      key: 'markdown:presentation:pageBreakSeparator',
+    });
+    await Config.findOneAndDelete({
+      key: 'markdown:presentation:pageBreakCustomSeparator',
+    });
 
     logger.info('Migration has successfully applied');
   },

+ 51 - 42
apps/app/src/migrations/20230723061824-granted-group-to-array-of-objects.js

@@ -10,21 +10,18 @@ module.exports = {
     const pageOperationCollection = await db.collection('pageoperations');
     // Convert grantedGroup to array
     // Set the model type of grantedGroup to UserGroup for Pages that were created before ExternalUserGroup was introduced
-    await pageCollection.updateMany(
-      { grantedGroup: { $ne: null } },
-      [
-        {
-          $set: {
-            grantedGroup: [
-              {
-                type: 'UserGroup',
-                item: '$grantedGroup',
-              },
-            ],
-          },
+    await pageCollection.updateMany({ grantedGroup: { $ne: null } }, [
+      {
+        $set: {
+          grantedGroup: [
+            {
+              type: 'UserGroup',
+              item: '$grantedGroup',
+            },
+          ],
         },
-      ],
-    );
+      },
+    ]);
 
     await pageOperationCollection.updateMany(
       { 'options.grantUserGroupId': { $ne: null } },
@@ -75,18 +72,24 @@ module.exports = {
     );
 
     // rename fields
-    await pageCollection.updateMany({}, {
-      $rename: {
-        grantedGroup: 'grantedGroups',
+    await pageCollection.updateMany(
+      {},
+      {
+        $rename: {
+          grantedGroup: 'grantedGroups',
+        },
       },
-    });
-    await pageOperationCollection.updateMany({}, {
-      $rename: {
-        'options.grantUserGroupId': 'options.grantUserGroupIds',
-        'page.grantedGroup': 'page.grantedGroups',
-        'exPage.grantedGroup': 'exPage.grantedGroups',
+    );
+    await pageOperationCollection.updateMany(
+      {},
+      {
+        $rename: {
+          'options.grantUserGroupId': 'options.grantUserGroupIds',
+          'page.grantedGroup': 'page.grantedGroups',
+          'exPage.grantedGroup': 'exPage.grantedGroups',
+        },
       },
-    });
+    );
 
     logger.info('Migration has successfully applied');
   },
@@ -97,22 +100,21 @@ module.exports = {
     const pageCollection = await db.collection('pages');
     const pageOperationCollection = await db.collection('pageoperations');
 
-    await pageCollection.updateMany(
-      { grantedGroups: { $exists: true } },
-      [
-        {
-          $set: {
-            grantedGroups: { $arrayElemAt: ['$grantedGroups.item', 0] },
-          },
+    await pageCollection.updateMany({ grantedGroups: { $exists: true } }, [
+      {
+        $set: {
+          grantedGroups: { $arrayElemAt: ['$grantedGroups.item', 0] },
         },
-      ],
-    );
+      },
+    ]);
     await pageOperationCollection.updateMany(
       { 'options.grantUserGroupIds': { $exists: true } },
       [
         {
           $set: {
-            'options.grantUserGroupIds': { $arrayElemAt: ['options.grantUserGroupIds.item', 0] },
+            'options.grantUserGroupIds': {
+              $arrayElemAt: ['options.grantUserGroupIds.item', 0],
+            },
           },
         },
       ],
@@ -122,7 +124,9 @@ module.exports = {
       [
         {
           $set: {
-            'page.grantedGroups': { $arrayElemAt: ['page.grantedGroups.item', 0] },
+            'page.grantedGroups': {
+              $arrayElemAt: ['page.grantedGroups.item', 0],
+            },
           },
         },
       ],
@@ -132,7 +136,9 @@ module.exports = {
       [
         {
           $set: {
-            'exPage.grantedGroups': { $arrayElemAt: ['exPage.grantedGroups.item', 0] },
+            'exPage.grantedGroups': {
+              $arrayElemAt: ['exPage.grantedGroups.item', 0],
+            },
           },
         },
       ],
@@ -147,13 +153,16 @@ module.exports = {
         },
       },
     );
-    await pageOperationCollection.updateMany({}, {
-      $rename: {
-        'options.grantUserGroupIds': 'options.grantUserGroupId',
-        'page.grantedGroups': 'page.grantedGroup',
-        'exPage.grantedGroups': 'exPage.grantedGroup',
+    await pageOperationCollection.updateMany(
+      {},
+      {
+        $rename: {
+          'options.grantUserGroupIds': 'options.grantUserGroupId',
+          'page.grantedGroups': 'page.grantedGroup',
+          'exPage.grantedGroups': 'exPage.grantedGroup',
+        },
       },
-    });
+    );
 
     logger.info('Migration has been successfully rollbacked');
   },

+ 18 - 11
apps/app/src/migrations/20230731075753-add_installed_date_to_config.js

@@ -23,11 +23,15 @@ module.exports = {
       // Set app:installed date.
       // refs: https://mongoosejs.com/docs/6.x/docs/timestamps.html#disabling-timestamps
       //       Read the section after "Disabling timestamps also lets you set timestamps yourself..."
-      const updatedConfig = await Config.findOneAndUpdate({ _id: appInstalled._id }, { createdAt: initialUserCreatedAt }, {
-        new: true,
-        timestamps: false,
-        strict: false,
-      });
+      const updatedConfig = await Config.findOneAndUpdate(
+        { _id: appInstalled._id },
+        { createdAt: initialUserCreatedAt },
+        {
+          new: true,
+          timestamps: false,
+          strict: false,
+        },
+      );
       logger.debug('updatedConfig: ', updatedConfig);
     }
 
@@ -40,13 +44,16 @@ module.exports = {
 
     const appInstalled = await Config.findOne({ key: 'app:installed' });
     if (appInstalled != null) {
-
       // Unset app:installed date.
-      const updatedConfig = await Config.findOneAndUpdate({ _id: appInstalled._id }, { $unset: { createdAt: 1 } }, {
-        new: true,
-        timestamps: false,
-        strict: false,
-      });
+      const updatedConfig = await Config.findOneAndUpdate(
+        { _id: appInstalled._id },
+        { $unset: { createdAt: 1 } },
+        {
+          new: true,
+          timestamps: false,
+          strict: false,
+        },
+      );
       logger.debug('updatedConfig: ', updatedConfig);
     }
 

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

@@ -3,7 +3,6 @@ import UserUISettings from '~/server/models/user-ui-settings';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:clean-user-ui-settings-collection');
 
 const mongoose = require('mongoose');

+ 6 - 9
apps/app/src/migrations/20231223155127-non-null-granted-groups.js

@@ -8,16 +8,13 @@ module.exports = {
 
     const pageCollection = await db.collection('pages');
 
-    await pageCollection.updateMany(
-      { grantedGroups: { $eq: null } },
-      [
-        {
-          $set: {
-            grantedGroups: [],
-          },
+    await pageCollection.updateMany({ grantedGroups: { $eq: null } }, [
+      {
+        $set: {
+          grantedGroups: [],
         },
-      ],
-    );
+      },
+    ]);
 
     logger.info('Migration has successfully applied');
   },

+ 9 - 10
apps/app/src/migrations/20240924181317-changed-status-in-inappnotifications-from-unread-to-unopened.js

@@ -1,22 +1,21 @@
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:changed-status-in-inappnotifications-from-unread-to-unopened');
+const logger = loggerFactory(
+  'growi:changed-status-in-inappnotifications-from-unread-to-unopened',
+);
 
 module.exports = {
   async up(db) {
     logger.info('Apply migration');
 
     const unreadInAppnotifications = await db.collection('inappnotifications');
-    await unreadInAppnotifications.updateMany(
-      { status: { $eq: 'UNREAD' } },
-      [
-        {
-          $set: {
-            status: 'UNOPENED',
-          },
+    await unreadInAppnotifications.updateMany({ status: { $eq: 'UNREAD' } }, [
+      {
+        $set: {
+          status: 'UNOPENED',
         },
-      ],
-    );
+      },
+    ]);
 
     logger.info('Migration has successfully applied');
   },

+ 19 - 12
apps/app/src/migrations/20241107172359-rename-pageId-to-page.js

@@ -4,12 +4,13 @@ import VectorStoreFileRelationModel from '~/features/openai/server/models/vector
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-
 const logger = loggerFactory('growi:migrate:rename-pageId-to-page');
 
 async function dropIndexIfExists(db, collectionName, indexName) {
   // check existence of the collection
-  const items = await db.listCollections({ name: collectionName }, { nameOnly: true }).toArray();
+  const items = await db
+    .listCollections({ name: collectionName }, { nameOnly: true })
+    .toArray();
   if (items.length === 0) {
     return;
   }
@@ -26,20 +27,26 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     // Drop index
-    await dropIndexIfExists(db, 'vectorstorefilerelations', 'vectorStoreRelationId_1_pageId_1');
+    await dropIndexIfExists(
+      db,
+      'vectorstorefilerelations',
+      'vectorStoreRelationId_1_pageId_1',
+    );
 
     // Rename field (pageId -> page)
-    await VectorStoreFileRelationModel.updateMany(
-      {},
-      [
-        { $set: { page: '$pageId' } },
-        { $unset: ['pageId'] },
-      ],
-    );
+    await VectorStoreFileRelationModel.updateMany({}, [
+      { $set: { page: '$pageId' } },
+      { $unset: ['pageId'] },
+    ]);
 
     // Create index
-    const collection = mongoose.connection.collection('vectorstorefilerelations');
-    await collection.createIndex({ vectorStoreRelationId: 1, page: 1 }, { unique: true });
+    const collection = mongoose.connection.collection(
+      'vectorstorefilerelations',
+    );
+    await collection.createIndex(
+      { vectorStoreRelationId: 1, page: 1 },
+      { unique: true },
+    );
   },
 
   async down() {

+ 30 - 9
apps/app/src/migrations/20250522105040-delete-old-index-for-vector-store-file-relation.js

@@ -3,11 +3,15 @@ import mongoose from 'mongoose';
 import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
 import loggerFactory from '~/utils/logger';
 
-const logger = loggerFactory('growi:migrate:vector-store-file-relation-index-migration');
+const logger = loggerFactory(
+  'growi:migrate:vector-store-file-relation-index-migration',
+);
 
 async function dropIndexIfExists(db, collectionName, indexName) {
   // check existence of the collection
-  const items = await db.listCollections({ name: collectionName }, { nameOnly: true }).toArray();
+  const items = await db
+    .listCollections({ name: collectionName }, { nameOnly: true })
+    .toArray();
   if (items.length === 0) {
     return;
   }
@@ -25,12 +29,20 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     // Drop old index
-    await dropIndexIfExists(db, 'vectorstorefilerelations', 'vectorStoreRelationId_1_page_1');
+    await dropIndexIfExists(
+      db,
+      'vectorstorefilerelations',
+      'vectorStoreRelationId_1_page_1',
+    );
 
     // Create index
-    const collection = mongoose.connection.collection('vectorstorefilerelations');
-    await collection.createIndex({ vectorStoreRelationId: 1, page: 1, attachment: 1 }, { unique: true });
-
+    const collection = mongoose.connection.collection(
+      'vectorstorefilerelations',
+    );
+    await collection.createIndex(
+      { vectorStoreRelationId: 1, page: 1, attachment: 1 },
+      { unique: true },
+    );
   },
   async down(db) {
     logger.info('Rollback migration');
@@ -38,10 +50,19 @@ module.exports = {
     await mongoose.connect(getMongoUri(), mongoOptions);
 
     // Drop new index
-    await dropIndexIfExists(db, 'vectorstorefilerelations', 'vectorStoreRelationId_1_page_1_attachment_1');
+    await dropIndexIfExists(
+      db,
+      'vectorstorefilerelations',
+      'vectorStoreRelationId_1_page_1_attachment_1',
+    );
 
     // Recreate old index
-    const collection = mongoose.connection.collection('vectorstorefilerelations');
-    await collection.createIndex({ vectorStoreRelationId: 1, page: 1 }, { unique: true });
+    const collection = mongoose.connection.collection(
+      'vectorstorefilerelations',
+    );
+    await collection.createIndex(
+      { vectorStoreRelationId: 1, page: 1 },
+      { unique: true },
+    );
   },
 };

+ 12 - 1
biome.json

@@ -25,7 +25,18 @@
       "!packages/pdf-converter-client/src/index.ts",
       "!apps/app/playwright/**",
       "!apps/app/public/**",
-      "!apps/app/src/**",
+      "!apps/app/src/client/**",
+      "!apps/app/src/components/**",
+      "!apps/app/src/features/**",
+      "!apps/app/src/interfaces/**",
+      "!apps/app/src/models/**",
+      "!apps/app/src/pages/**",
+      "!apps/app/src/server/**",
+      "!apps/app/src/services/**",
+      "!apps/app/src/stores/**",
+      "!apps/app/src/stores-universal/**",
+      "!apps/app/src/styles/**",
+      "!apps/app/src/utils/**",
       "!apps/app/test/integration/service/**",
       "!apps/app/test-with-vite/**"
     ]