diff --git a/packages/model/src/migration.ts b/packages/model/src/migration.ts index d59e3b2035..d38add6d8e 100644 --- a/packages/model/src/migration.ts +++ b/packages/model/src/migration.ts @@ -99,7 +99,12 @@ export interface MigrationClient { ) => Promise // Move documents per domain - move: (sourceDomain: Domain, query: DocumentQuery, targetDomain: Domain) => Promise + move: ( + sourceDomain: Domain, + query: DocumentQuery, + targetDomain: Domain, + size?: number + ) => Promise create: (domain: Domain, doc: T | T[]) => Promise delete: (domain: Domain, _id: Ref) => Promise diff --git a/server/tool/src/upgrade.ts b/server/tool/src/upgrade.ts index 0a178650c4..84365296af 100644 --- a/server/tool/src/upgrade.ts +++ b/server/tool/src/upgrade.ts @@ -70,11 +70,16 @@ export class MigrateClientImpl implements MigrationClient { } } - async move(sourceDomain: Domain, query: DocumentQuery, targetDomain: Domain): Promise { + async move( + sourceDomain: Domain, + query: DocumentQuery, + targetDomain: Domain, + size = 500 + ): Promise { const ctx = new MeasureMetricsContext('move', {}) this.logger.log('move', { sourceDomain, query }) while (true) { - const source = await this.lowLevel.rawFindAll(sourceDomain, query, { limit: 500 }) + const source = await this.lowLevel.rawFindAll(sourceDomain, query, { limit: size }) if (source.length === 0) break await this.lowLevel.upload(ctx, targetDomain, source) await this.lowLevel.clean( diff --git a/services/github/model-github/src/migration.ts b/services/github/model-github/src/migration.ts index fb2173b0fe..f0de51684b 100644 --- a/services/github/model-github/src/migration.ts +++ b/services/github/model-github/src/migration.ts @@ -332,7 +332,7 @@ export const githubOperationPreTime: MigrateOperation = { { state: 'migrate-github-sync-domain', func: async (client) => { - await client.move(DOMAIN_GITHUB, { _class: github.class.DocSyncInfo }, DOMAIN_GITHUB_SYNC) + await client.move(DOMAIN_GITHUB, { _class: github.class.DocSyncInfo }, DOMAIN_GITHUB_SYNC, 100) await client.move(DOMAIN_GITHUB, { _class: github.class.GithubUserInfo }, DOMAIN_GITHUB_USER) } }