Skip to content

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

Merged
meladRaouf merged 1 commit into
mainfrom
feature/make-room-default
Jul 30, 2026
Merged

[MS-1516] Force Room as default database after a fresh user login#1758
meladRaouf merged 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.

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.

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 no new comments.

Comments suppressed due to low confidence (2)

infra/enrolment-records/repository/src/main/java/com/simprints/infra/enrolment/records/repository/local/migration/RealmToRoomMigrationWorker.kt:76

  • CancellationException is treated as an expected cancellation here, but it can still be logged as an error earlier in processRecords() (the catch (e: Exception) around roomDataSource.performActions(...) will catch CancellationException too). That can create noisy error logs/Crashlytics signals for deliberate cancellations (e.g. forceRoomAsDefaultDatabase()). Consider adding a dedicated catch (e: CancellationException) { throw e } before the generic catch inside processRecords() to avoid logging cancellations as errors.
        } 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

infra/enrolment-records/repository/src/main/java/com/simprints/infra/enrolment/records/repository/local/migration/RealmToRoomMigrationScheduler.kt:43

  • The KDoc says this “forces Room … ignoring the migration flags”, but the implementation actually overrides the flags by setting MigrationStatus.COMPLETED (which elsewhere is documented as “Migration finished successfully”). This is potentially misleading for future maintainers since no migration is performed here; consider clarifying in the KDoc that this marks the migration as completed to switch the default DB and does not migrate existing Realm data.
    /**
     * Forces Room to become the default enrolment records database immediately, ignoring the migration flags
     */
    suspend fun forceRoomAsDefaultDatabase() {

@meladRaouf
meladRaouf marked this pull request as ready for review July 29, 2026 10:22
@meladRaouf
meladRaouf force-pushed the feature/make-room-default branch from 4f4b472 to a53d9b5 Compare July 29, 2026 11:23
@sonarqubecloud

Copy link
Copy Markdown

@meladRaouf
meladRaouf merged commit d97880a into main Jul 30, 2026
14 checks passed
@meladRaouf
meladRaouf deleted the feature/make-room-default branch July 30, 2026 07:29
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.

3 participants