فهرست منبع

Added process

Taichi Masuyama 4 سال پیش
والد
کامیت
7aadd8bf77

+ 10 - 1
packages/app/src/server/routes/apiv3/import.js

@@ -1,3 +1,5 @@
+import mongoose from 'mongoose';
+
 import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:routes:apiv3:import'); // eslint-disable-line no-unused-vars
@@ -267,7 +269,14 @@ module.exports = (crowi) => {
      * import
      */
     try {
-      importService.import(collections, importSettingsMap);
+      (async() => {
+        // set isV5Compatible to false
+        await crowi.configManager.updateConfigsInTheSameNamespace('crowi', { 'app:isV5Compatible': false });
+        // import
+        await importService.import(collections, importSettingsMap);
+        // run v5InitialMigration
+        await crowi.pageService.v5InitialMigration();
+      })();
     }
     catch (err) {
       logger.error(err);

+ 4 - 0
packages/app/src/server/routes/apiv3/overwrite-params/pages.js

@@ -45,6 +45,10 @@ class PageOverwriteParamsFactory {
       return null;
     };
 
+    params.descendantCount = (value, { document, schema, propertyName }) => {
+      return 0;
+    };
+
     if (option.initPageMetadatas) {
       params.liker = [];
       params.seenUsers = [];

+ 1 - 2
packages/app/src/server/routes/apiv3/pages.js

@@ -710,12 +710,11 @@ module.exports = (crowi) => {
 
   router.post('/v5-schema-migration', accessTokenParser, loginRequired, adminRequired, csrf, async(req, res) => {
     const isV5Compatible = crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
-    const Page = crowi.model('Page');
 
     try {
       if (!isV5Compatible) {
         // this method throws and emit socketIo event when error occurs
-        crowi.pageService.v5InitialMigration(Page.GRANT_PUBLIC); // not await
+        crowi.pageService.v5InitialMigration(); // not await
       }
     }
     catch (err) {

+ 3 - 2
packages/app/src/server/service/page.ts

@@ -1878,7 +1878,7 @@ class PageService {
   }
 
   // TODO: use socket to send status to the client
-  async v5InitialMigration(grant) {
+  async v5InitialMigration() {
     // const socket = this.crowi.socketIoService.getAdminSocket();
 
     let isUnique;
@@ -1904,7 +1904,8 @@ class PageService {
 
     // then migrate
     try {
-      await this.normalizeParentRecursively(grant, null, true);
+      const Page = mongoose.model('Page') as unknown as PageModel;
+      await this.normalizeParentRecursively(Page.GRANT_PUBLIC, null, true);
     }
     catch (err) {
       logger.error('V5 initial miration failed.', err);