Skip to content

Migrate to Room 3 - #295

Merged
Goooler merged 3 commits into
trunkfrom
migrate-to-room-3
Jun 1, 2026
Merged

Goooler merged 3 commits into
trunkfrom
migrate-to-room-3

Conversation

@Goooler

@Goooler Goooler commented Jun 1, 2026

Copy link
Copy Markdown
Owner
Version 3.0.0-alpha01
March 11, 2026

androidx.room3:room3-*:3.0.0-alpha01 is released.

Room 3.0 (package androidx.room3) is a major version update of Room 2.x package (androidx.room) that focuses on Kotlin Multiplatform (KMP).

The core annotation APIs are kept the same along with the main components:

An abstract class that extends androidx.room3.RoomDatabase and is annotated with @Database is the entry point for Room's annotation processor.
The database declaration has one or more data classes describing the database schema and are annotated with @Entity.
Database operations are defined in @Dao declarations that contains query functions whose SQL statements are defined via the @Query annotation.
At runtime, the database implementation can be obtained via a RoomDatabase.Builder which is also used to configure the database.
Most of the documentation in the Save data in a local database using Room guide is still relevant to Room 3.0.

The major breaking differences between Room 2.x are as follows:

New package, androidx.room3.
SupportSQLite APIs are no longer supported, unless you are using the androidx.room3:room3-sqlite-wrapper.
All database operations are now Coroutine APIs based.
Kotlin code generation only.
Kotlin Symbol Processing (KSP) is required.
Along with breaking changes, Room 3.0 brings in new functionality compared to 2.x:

JS and WasmJS Support
Custom DAO Return Types

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 migrates the service module’s persistence layer from Room 2 (androidx.room) to Room 3 (androidx.room3), aligning the codebase with Room 3’s coroutine-first APIs and updated artifacts.

Changes:

  • Switched Room imports in DAOs/entities/type converters/database to androidx.room3.
  • Updated DAO write methods to suspend and adjusted a synchronous call site to use a coroutine.
  • Updated Gradle dependencies/version catalog to use androidx.room3:* artifacts and removed room-ktx.

Reviewed changes

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

Show a summary per file
File Description
service/src/main/kotlin/com/github/kr328/clash/service/data/SelectionDao.kt Migrates DAO annotations to Room 3 and makes write APIs suspend.
service/src/main/kotlin/com/github/kr328/clash/service/data/Selection.kt Migrates entity annotations/imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/RoomTypeConverters.kt Migrates type converter annotation import to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/PendingDao.kt Migrates DAO annotations/imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/Pending.kt Migrates entity annotations/imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/ImportedDao.kt Migrates DAO annotations/imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/Imported.kt Migrates entity annotations/imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/data/Database.kt Migrates database definition/builder imports to Room 3.
service/src/main/kotlin/com/github/kr328/clash/service/ClashManager.kt Adjusts selection persistence call site for suspend DAO APIs.
service/build.gradle.kts Removes room-ktx and keeps Room compiler/runtime wiring via KSP.
gradle/libs.versions.toml Updates Room version and switches artifacts to androidx.room3:*.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Goooler
Goooler merged commit 85351fe into trunk Jun 1, 2026
3 checks passed
@Goooler
Goooler deleted the migrate-to-room-3 branch June 1, 2026 05:01
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