[MS-1516] Force Room as default database after a fresh user login - #1758
Draft
meladRaouf wants to merge 1 commit into
Draft
[MS-1516] Force Room as default database after a fresh user login#1758meladRaouf wants to merge 1 commit into
meladRaouf wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
LoginCheckViewModelto 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() | ||
| } |
meladRaouf
force-pushed
the
feature/make-room-default
branch
from
July 27, 2026 14:53
ede3611 to
e644520
Compare
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
force-pushed
the
feature/make-room-default
branch
from
July 27, 2026 15:07
e644520 to
4f4b472
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA ticket
Will be released in: 2026.3.0
Notable changes
Testing guidance
Additional work checklist