Skip to content

Conversation

@joshuatam
Copy link
Contributor

@joshuatam joshuatam commented Jan 9, 2026

Avoid data get wiped on version upgrade from 8 -> 10

Especially when user installed 0.6.2, later install GOG version / Game Manager version, all db data will got wiped due to db version upgrade.

Reference:
Check auto migration here
https://developer.android.com/training/data-storage/room/migrating-db-versions#automated

Summary by CodeRabbit

  • Chores

    • Migrated project to Room's official plugin and DSL for schema management.
    • Exported and organized schema snapshots for clearer versioning and inspection.
  • New Features

    • Enabled exported schemas and added automatic database auto-migrations to allow seamless in-place upgrades without user data loss.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Configures Room via the Gradle Room plugin DSL (plugin alias and libs.versions.toml entry), moves Room schema export into the Room DSL in app/build.gradle.kts (removes previous KSP args), adds schema snapshot JSONs for versions 8–10, and enables Room auto-migrations (8→9, 9→10) with exportSchema = true on PluviaDatabase.

Changes

Cohort / File(s) Summary
Build files
app/build.gradle.kts, gradle/libs.versions.toml
Added Room plugin alias in gradle/libs.versions.toml; switched app/build.gradle.kts to use alias(libs.plugins.room) and added room { schemaDirectory("$projectDir/schemas") }; removed previous KSP arg("room.schemaLocation", ...) and room.incremental args.
Database source
app/src/main/java/app/gamenative/db/PluviaDatabase.kt
Updated @Database annotation to exportSchema = true and added autoMigrations = [ AutoMigration(from = 8, to = 9), AutoMigration(from = 9, to = 10) ].
Schema snapshots
app/schemas/app.gamenative.db.PluviaDatabase/8.json, .../9.json, .../10.json
Added/updated Room-exported JSON schema snapshots for database versions 8, 9, and 10 (table CREATE statements, field mappings, primary keys, and room_master_table identity hashes).

Sequence Diagram(s)

(Skipped — changes are configuration, schema snapshots, and annotation updates without a new multi-component runtime control flow requiring visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I nibbled at schemas, neat and keen,
From eight to nine, then ten was seen,
A plugin planted, KSP set free,
Migrations hop along with glee,
Build carrots crunchy — database green.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix auto migration' directly aligns with the PR's primary objective of implementing Room auto migrations to prevent data loss during database upgrades from version 8 to 10.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b68e56 and 08abfd3.

📒 Files selected for processing (1)
  • gradle/libs.versions.toml
⏰ 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: build
🔇 Additional comments (2)
gradle/libs.versions.toml (2)

118-118: LGTM! Plugin enables automated migrations.

The Room plugin declaration correctly references the same version as the Room libraries and is essential for enabling the Room Gradle plugin DSL. This allows configuring automated migrations in app/build.gradle.kts to prevent data loss during database upgrades, addressing the core issue described in the PR objectives.


33-33: The upgrade from release candidate (2.8.0-rc02) to stable version 2.8.4 is appropriate for production use. Version 2.8.4 is the latest stable release of androidx.room (released November 19, 2025) and has no known security vulnerabilities in the core library.


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.

@joshuatam joshuatam marked this pull request as ready for review January 9, 2026 16:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/build.gradle.kts (1)

86-86: Address the deprecated resourceConfigurations warning.

The pipeline indicates that resourceConfigurations is deprecated. Consider migrating to the recommended androidResources.localeFilters API.

♻️ Suggested migration to new API
-        resourceConfigurations += listOf(
+        androidResources {
+            localeFilters += listOf(
-            "en",      // English (default)
-            "da",      // Danish
-            "pt-rBR",  // Portuguese (Brazilian)
-            "zh-rTW",  // Traditional Chinese
-            "zh-rCN",  // Simplified Chinese
-            "fr",      // French
-            "de",      // German
-            "uk",      // Ukrainian
-            "it",      // Italian
-            // TODO: Add more languages here using the ISO 639-1 locale code with regional qualifiers (e.g., "pt-rPT" for European Portuguese)
-        )
+                "en",      // English (default)
+                "da",      // Danish
+                "pt-rBR",  // Portuguese (Brazilian)
+                "zh-rTW",  // Traditional Chinese
+                "zh-rCN",  // Simplified Chinese
+                "fr",      // French
+                "de",      // German
+                "uk",      // Ukrainian
+                "it",      // Italian
+                // TODO: Add more languages here using the ISO 639-1 locale code with regional qualifiers (e.g., "pt-rPT" for European Portuguese)
+            )
+        }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 175e715 and 8deaa7e.

📒 Files selected for processing (5)
  • app/build.gradle.kts
  • app/schemas/app.gamenative.db.PluviaDatabase/10.json
  • app/schemas/app.gamenative.db.PluviaDatabase/9.json
  • app/src/main/java/app/gamenative/db/PluviaDatabase.kt
  • gradle/libs.versions.toml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-28T13:56:06.888Z
Learnt from: utkarshdalal
Repo: utkarshdalal/GameNative PR: 176
File: app/src/main/java/app/gamenative/service/SteamService.kt:179-180
Timestamp: 2025-09-28T13:56:06.888Z
Learning: In the GameNative project, the AppInfo table (with AppInfoDao) tracks local game installation state including which apps are downloaded and which depots were installed. This data should NOT be cleared during logout in clearDatabase() because games remain physically installed on the device and users should see their installed games when logging back in. Only user-specific Steam account data should be cleared on logout.

Applied to files:

  • app/schemas/app.gamenative.db.PluviaDatabase/9.json
  • app/schemas/app.gamenative.db.PluviaDatabase/10.json
🪛 GitHub Actions: Pull Request build check
app/build.gradle.kts

[warning] 86-86: Deprecated: 'resourceConfigurations: MutableSet' is deprecated. Support for resource configurations will be removed. For language resource configurations in applications, use androidResources.localeFilters.

🔇 Additional comments (8)
gradle/libs.versions.toml (2)

118-118: LGTM! Room plugin properly configured.

The Room plugin declaration correctly references the room-runtime version.


129-133: LGTM! Room bundle properly structured.

The bundle consolidates the three main Room dependencies (runtime, ktx, paging) for easier dependency management.

app/src/main/java/app/gamenative/db/PluviaDatabase.kt (2)

3-3: LGTM! Required import added.

The AutoMigration import is necessary for the new migration configuration.


48-54: AutoMigration correctly adds the downloading_app_info table.

The DownloadingAppInfo entity is properly configured with @entity annotation, @PrimaryKey, and @ColumnInfo mappings. The schema migration from version 9 to 10 cleanly adds the table, and Room's AutoMigration handles this simple additive change appropriately.

app/build.gradle.kts (2)

13-13: LGTM! Room plugin properly applied.

The Room plugin is correctly added using the version catalog alias.


32-34: LGTM! Room schema directory properly configured.

The new Room DSL configuration correctly sets the schema directory for exporting database schemas, which is essential for the AutoMigration feature to work properly.

app/schemas/app.gamenative.db.PluviaDatabase/10.json (1)

1-796: LGTM! Version 10 schema properly exported.

The schema file is auto-generated by Room and correctly defines the database structure for version 10, including the new downloading_app_info table. The identity hash and setupQueries are properly configured.

app/schemas/app.gamenative.db.PluviaDatabase/9.json (1)

1-772: LGTM! Version 9 schema properly exported.

The schema file correctly represents the baseline database structure for version 9. This serves as the starting point for the AutoMigration to version 10.

Avoid data get wiped on version upgrade from 8 -> 10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @gradle/libs.versions.toml:
- Line 118: Update the Room dependency to the stable 2.8.4 release by changing
the version referenced by the room alias: locate the entry with room = { id =
"androidx.room", version.ref = "room-runtime" } and update the version value
referenced by "room-runtime" in libs.versions.toml from the RC (2.8.0-rc02) to
the stable 2.8.4 so the room alias resolves to androidx.room:2.8.4.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8deaa7e and 3b68e56.

📒 Files selected for processing (6)
  • app/build.gradle.kts
  • app/schemas/app.gamenative.db.PluviaDatabase/10.json
  • app/schemas/app.gamenative.db.PluviaDatabase/8.json
  • app/schemas/app.gamenative.db.PluviaDatabase/9.json
  • app/src/main/java/app/gamenative/db/PluviaDatabase.kt
  • gradle/libs.versions.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/build.gradle.kts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-28T13:56:06.888Z
Learnt from: utkarshdalal
Repo: utkarshdalal/GameNative PR: 176
File: app/src/main/java/app/gamenative/service/SteamService.kt:179-180
Timestamp: 2025-09-28T13:56:06.888Z
Learning: In the GameNative project, the AppInfo table (with AppInfoDao) tracks local game installation state including which apps are downloaded and which depots were installed. This data should NOT be cleared during logout in clearDatabase() because games remain physically installed on the device and users should see their installed games when logging back in. Only user-specific Steam account data should be cleared on logout.

Applied to files:

  • app/schemas/app.gamenative.db.PluviaDatabase/9.json
  • app/schemas/app.gamenative.db.PluviaDatabase/10.json
⏰ 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: build
🔇 Additional comments (5)
app/schemas/app.gamenative.db.PluviaDatabase/8.json (1)

1-652: Schema snapshot for version 8 looks correct.

This Room-generated schema file serves as the baseline for the 8→9 auto-migration. The schema defines 7 tables and will be used by Room at build time to verify migration correctness.

app/src/main/java/app/gamenative/db/PluviaDatabase.kt (2)

50-50: Good practice: enabling schema export.

Enabling exportSchema = true with the helpful comment about handling DB changes carefully aligns well with the PR objective to prevent data loss on upgrades.


48-55: Auto-migration setup is correct for versions 8→10.

The additive schema changes (new tables only) are well-suited for Room's auto-migration without requiring AutoMigrationSpec. The migration strategy comprehensively handles all database versions: fallbackToDestructiveMigration(true) handles upgrades from versions < 7, a manual migration covers v7→v8, and auto-migrations handle v8→10.

app/schemas/app.gamenative.db.PluviaDatabase/10.json (1)

1-796: Schema snapshot for version 10 is correct.

The schema correctly adds the downloading_app_info table compared to version 9, matching the DownloadingAppInfo::class entity declared in PluviaDatabase.kt. This additive change is suitable for auto-migration.

app/schemas/app.gamenative.db.PluviaDatabase/9.json (1)

1-772: Schema snapshot for version 9 is correct.

The schema correctly adds the gog_games table compared to version 8, matching the GOGGame::class entity. The identity hash (12c9ce07ac85aa0a7b83c81705f4596d) is consistent between the header and setupQueries.

Updates the Room runtime library to the latest stable version.
@utkarshdalal utkarshdalal merged commit 707308b into utkarshdalal:master Jan 10, 2026
1 of 2 checks passed
@joshuatam joshuatam deleted the fix/auto-migration branch January 11, 2026 07:24
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.

2 participants