Skip to content

[MS-1516] Force Room as default database after a fresh user login - #1758

Draft
meladRaouf wants to merge 1 commit into
mainfrom
feature/make-room-default
Draft

[MS-1516] Force Room as default database after a fresh user login#1758
meladRaouf wants to merge 1 commit into
mainfrom
feature/make-room-default

Conversation

@meladRaouf

Copy link
Copy Markdown
Collaborator

JIRA ticket
Will be released in: 2026.3.0

Notable changes

  • Once login SID will default to ROOM DB

Testing guidance

  • Log in to SID and check the database migration logs in the Troubleshooting screen to verify that Room is the default database.
  • If you are already logged in the DB will still be the same

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the post-login flow so that after a fresh SID login, the app immediately treats Room as the default enrolment records database (instead of allowing the Realm→Room migration mechanism to determine the active DB), aligning with MS-1516.

Changes:

  • Added forceRoomAsDefaultDatabase() to cancel the migration worker and mark the Realm→Room migration as completed.
  • Updated LoginCheckViewModel to call the new force method only after a fresh login (and not for already-signed-in users).
  • Added/updated tests covering the new “fresh login forces Room” behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
infra/enrolment-records/repository/src/main/java/com/simprints/infra/enrolment/records/repository/local/migration/RealmToRoomMigrationScheduler.kt Adds a new API to force Room as default by cancelling migration work and updating migration flags.
infra/enrolment-records/repository/src/test/java/com/simprints/infra/enrolment/records/repository/local/migration/RealmToRoomMigrationSchedulerTest.kt Adds test coverage for the new scheduler method behavior.
feature/login-check/src/main/java/com/simprints/feature/logincheck/LoginCheckViewModel.kt Threads “fresh login” state into the flow and triggers forcing Room only after a successful fresh login.
feature/login-check/src/test/java/com/simprints/feature/logincheck/LoginCheckViewModelTest.kt Adds tests asserting the force behavior happens only on fresh login and not for already signed-in users.

Comment on lines +44 to +49
suspend fun forceRoomAsDefaultDatabase() {
log("Forcing Room as default database after login, ignoring migration flags.")
workManager.cancelUniqueWork(RealmToRoomMigrationWorker.WORK_NAME)
realmToRoomMigrationFlagsStore.updateStatus(MigrationStatus.COMPLETED)
realmToRoomMigrationFlagsStore.resetRetryCount()
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment on lines +26 to +29
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertThrows
}

@Test
fun `doWork should rethrow CancellationException without touching flags or deleting Room data`() = runTest {
Comment on lines +214 to +217
// When / Then
assertThrows(CancellationException::class.java) {
runBlocking { worker.doWork() }
}
Comment on lines +73 to +76
} catch (e: CancellationException) {
// The work may have been canceled deliberately (e.g. forceRoomAsDefaultDatabase())
Simber.i("[RealmToRoomMigrationWorker] Migration cancelled: ${e.message}", tag = REALM_DB_MIGRATION)
throw e
@meladRaouf
meladRaouf force-pushed the feature/make-room-default branch from e644520 to 4f4b472 Compare July 27, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants