|
@@ -74,6 +74,7 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|
private async migrateRevisionsForUser(userUuid: Uuid): Promise<Result<void>> {
|
|
private async migrateRevisionsForUser(userUuid: Uuid): Promise<Result<void>> {
|
|
try {
|
|
try {
|
|
const totalRevisionsCountForUser = await this.primaryRevisionsRepository.countByUserUuid(userUuid)
|
|
const totalRevisionsCountForUser = await this.primaryRevisionsRepository.countByUserUuid(userUuid)
|
|
|
|
+ let totalRevisionsCountTransitionedToSecondary = 0
|
|
const pageSize = 1
|
|
const pageSize = 1
|
|
const totalPages = Math.ceil(totalRevisionsCountForUser / pageSize)
|
|
const totalPages = Math.ceil(totalRevisionsCountForUser / pageSize)
|
|
for (let currentPage = 1; currentPage <= totalPages; currentPage++) {
|
|
for (let currentPage = 1; currentPage <= totalPages; currentPage++) {
|
|
@@ -91,6 +92,7 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|
if (!didSave) {
|
|
if (!didSave) {
|
|
return Result.fail(`Failed to save revision ${revision.id.toString()} to secondary database`)
|
|
return Result.fail(`Failed to save revision ${revision.id.toString()} to secondary database`)
|
|
}
|
|
}
|
|
|
|
+ totalRevisionsCountTransitionedToSecondary++
|
|
} catch (error) {
|
|
} catch (error) {
|
|
return Result.fail(
|
|
return Result.fail(
|
|
`Errored when saving revision ${revision.id.toString()} to secondary database: ${
|
|
`Errored when saving revision ${revision.id.toString()} to secondary database: ${
|
|
@@ -101,6 +103,8 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.logger.info(`Transitioned ${totalRevisionsCountTransitionedToSecondary} revisions to secondary database`)
|
|
|
|
+
|
|
return Result.ok()
|
|
return Result.ok()
|
|
} catch (error) {
|
|
} catch (error) {
|
|
return Result.fail(`Errored when migrating revisions for user ${userUuid.value}: ${(error as Error).message}`)
|
|
return Result.fail(`Errored when migrating revisions for user ${userUuid.value}: ${(error as Error).message}`)
|