Skip to content

fix(database): enable Room schema export for future migrations - #2695

Merged
niyajali merged 1 commit into
openMF:devfrom
sahilshivekar:enable-migration
Jun 24, 2026
Merged

fix(database): enable Room schema export for future migrations#2695
niyajali merged 1 commit into
openMF:devfrom
sahilshivekar:enable-migration

Conversation

@sahilshivekar

Copy link
Copy Markdown
Contributor

Fixes - Jira-#782

@sahilshivekar
sahilshivekar requested a review from a team June 19, 2026 09:51
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0711d042-ba5b-41a7-93c3-57be9c3db193

📥 Commits

Reviewing files that changed from the base of the PR and between ca68ef2 and 8306b66.

📒 Files selected for processing (5)
  • core/database/schemas/com.mifos.room.MifosDatabase/1.json
  • core/database/schemas/com.mifos.room.db.MifosDatabase/1.json
  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
💤 Files with no reviewable changes (1)
  • core/database/schemas/com.mifos.room.db.MifosDatabase/1.json
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🧰 Additional context used
📓 Path-based instructions (3)
**/*Database.kt

⚙️ CodeRabbit configuration file

**/*Database.kt: Room Database Migration Rules:

  • If there is any change to a Room schema (fields added, removed, or modified in any @Entity class), the version number in the @Database annotation MUST be incremented.
  • Verify if a migration strategy (e.g., Migration or autoMigrations) has been implemented for the version bump.
  • Flag schema changes that do not accompany a database version increment to prevent runtime crashes.

Files:

  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
**/{core-base,core}/**/*.kt

⚙️ CodeRabbit configuration file

**/{core-base,core}/**/*.kt: Critical Module Change Detection:

  • Changes in core-base module must be treated as high-impact.
  • Flag any PR that modifies files inside core-base for careful review.
  • Verify that modifications in core-base are necessary and minimal.
    Output:
  • Clearly highlight that core-base is a shared foundational module and requires extra review attention.

Files:

  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
**/*.kt

⚙️ CodeRabbit configuration file

**/*.kt: Additional Code Review Guidelines:

  1. Null Safety & Stability
  • Avoid using !! operator
  • Handle null cases explicitly using safe calls or proper state handling
  • Do not assume values are always non-null without guarantees
  1. Architecture Boundaries
  • ViewModel must not depend on specific network/library implementations
  • Ensure proper separation between data, domain, and presentation layers
  • Do not format data (currency, dates, calculations) inside the UI layer
  • All formatting must be handled in the ViewModel and exposed via state (e.g., StateFlow)
  1. Performance Considerations
  • Avoid unnecessary recompositions in Compose
  • Do not attach heavy logic to frequently changing states (e.g., scrollState)
  • Prefer lifting state up instead of recomputing in child composables
  1. Compose & Navigation Best Practices
  • NEVER trigger navigation functions or side-effects directly during composition
  • Always wrap navigation calls inside LaunchedEffect or EventsEffect to avoid repeated execution on recomposition
  • Avoid triggering intensive side-effects during recomposition
  • Navigation routes must be type-safe.
  • Ensure all route classes or objects used for navigation are annotated with @Serializable.
  1. UI Structure
  • Dialogs must be separated into their own composables
  • Do not embed dialogs inline within complex main screens
  1. Localization Consistency
  • Ensure all supported languages are updated consistently across modules
  • Verify translations exist for newly added UI strings
  1. Code Cleanliness
  • Avoid unnecessary inline comments unless critical
  • Remove leftover debug or commented code
  1. Focus on correctness, readability, and maintainability over cosmetic nitpicks.
  • Avoid reviewing README, config, or asset files.
  • Prioritize identifying bugs, performance issues, and architectural concerns.
  1. Naming & Intent Rules:

Files:

  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
🧠 Learnings (2)
📚 Learning: 2026-02-06T13:15:16.968Z
Learnt from: sahilshivekar
Repo: openMF/android-client PR: 2603
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanTransaction/LoanTransactionsViewModel.kt:43-106
Timestamp: 2026-02-06T13:15:16.968Z
Learning: Guideline: When a Kotlin function parameter is nullable (e.g., balance: Double?, currencyCode: String?, maximumFractionDigits: Int?) and downstream calls require a non-null value, add null-safety handling in all implementations. Specifically, avoid calling Currency.getInstance(currencyCode) with a possibly null currencyCode; provide a safe default (e.g., currencyCode ?: "$") or validate before use. Ensure all platform targets (Android/Desktop/Native) follow consistent null handling, and consider centralizing currencyCode normalization in the common layer if feasible. Add tests covering null currencyCode to prevent NPEs.

Applied to files:

  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
📚 Learning: 2026-04-01T05:03:14.323Z
Learnt from: kartikey004
Repo: openMF/mifos-x-field-officer-app PR: 2659
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementScreen.kt:190-195
Timestamp: 2026-04-01T05:03:14.323Z
Learning: In this repo, existing `SelectableDates` / `SelectableDates.isSelectableDate(utcTimeMillis: Long)` implementations use `Clock.System.now().toEpochMilliseconds()` (UTC epoch millis) for date-boundary checks. During PR reviews, do not flag these checks for not using a timezone-aware `LocalDate` start-of-day approach; treat it as an established project-wide pattern. If a change is desired, handle it as a coordinated project-wide improvement rather than as a per-PR review issue.

Applied to files:

  • core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt
  • core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt
🔇 Additional comments (3)
core/database/src/desktopMain/kotlin/com/mifos/room/MifosDatabase.kt (1)

153-153: LGTM!

core/database/src/nativeMain/kotlin/com/mifos/room/MifosDatabase.kt (1)

155-155: LGTM!

core/database/src/androidMain/kotlin/com/mifos/room/MifosDatabase.kt (1)

153-153: No action needed — baseline schema is properly committed.

The concern in the original comment was based on an incorrect assumption. The baseline schema file exists at core/database/schemas/com.mifos.room.MifosDatabase/1.json (4190 lines, valid) and is checked into the repository. The exportSchema = true setting on line 153 is correctly paired with the schemaDirectory configuration in the build logic, ensuring that future schema changes will be automatically exported. With VERSION = 1 and no migrations required yet, the setup is sound and ready for future version increments.

			> Likely an incorrect or invalid review comment.

Summary by CodeRabbit

  • Chores
    • Updated database schema export configuration across all platforms to enhance schema tracking and versioning capabilities.

Walkthrough

The @Database annotation's exportSchema flag is switched from false to true across all three platform-specific MifosDatabase.kt files (androidMain, desktopMain, nativeMain). The existing schema JSON file (1.json, 1178 lines) is deleted with no replacement provided in this diff.

Changes

Enable Room Schema Export

View checkpoint table
Layer / File(s) Summary
Enable exportSchema across all platform targets
core/database/src/androidMain/.../MifosDatabase.kt, core/database/src/desktopMain/.../MifosDatabase.kt, core/database/src/nativeMain/.../MifosDatabase.kt, core/database/schemas/.../1.json
exportSchema is set to true in @Database for all three platform targets; the prior schema JSON (1.json, 1178 lines) is removed with no regenerated replacement present in this diff.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Jira Link And Before/After Sections ❌ Error PR description contains valid Jira link but is missing required non-empty Before/After sections with media. Add Before and After sections to PR description, each with supporting images or videos showing the change.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: enabling Room schema export in the database module, which aligns with the code modifications across multiple database files.
Description check ✅ Passed The description references the Jira ticket (MIFOSAC-782) and is related to the changeset, though minimal in detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@biplab1 biplab1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@niyajali
niyajali merged commit c997b69 into openMF:dev Jun 24, 2026
10 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants