diff --git a/apps/server/src/modules/user-login-migration/service/user-login-migration.service.ts b/apps/server/src/modules/user-login-migration/service/user-login-migration.service.ts index 6cdae6f7ee8..f39c5534414 100644 --- a/apps/server/src/modules/user-login-migration/service/user-login-migration.service.ts +++ b/apps/server/src/modules/user-login-migration/service/user-login-migration.service.ts @@ -67,12 +67,15 @@ export class UserLoginMigrationService { userLoginMigration.finishedAt = oauthMigrationFinished ? new Date(Date.now() + (Configuration.get('MIGRATION_END_GRACE_PERIOD_MS') as number)) : undefined; - - await this.schoolService.removeFeature(schoolId, SchoolFeatures.ENABLE_LDAP_SYNC_DURING_MIGRATION); } const savedMigration: UserLoginMigrationDO = await this.userLoginMigrationRepo.save(userLoginMigration); + // userLoginMigration throws an error when saved, if this codeblock runs before the userLoginMigrationRepo.save method. + if (oauthMigrationFinished !== undefined) { + await this.schoolService.removeFeature(schoolId, SchoolFeatures.ENABLE_LDAP_SYNC_DURING_MIGRATION); + } + return savedMigration; }