top of page

SQLDelight Migration Guide: Room to Multiplatform

Migrating from Room to SQLDelight is one of the most common steps when adopting Kotlin Multiplatform. At MBS, we've migrated three production apps. Here's the step-by-step guide we wish we had when we started.

Why SQLDelight?

Room is Android-only. SQLDelight generates Kotlin code from SQL statements and works across Android, iOS, Desktop, and Web. It gives you type-safe queries, automatic schema migrations, and coroutine/flow support — all shared across platforms.

Step 1: Map Your Room Entities

Start by listing all Room @Entity classes and their @Dao interfaces. For each entity, you'll create a .sq file with CREATE TABLE and query statements. Room annotations map directly to SQL: @PrimaryKey becomes PRIMARY KEY, @ColumnInfo maps to column names, and @Relation becomes a JOIN query.

Step 2: Write SQL Schemas

Create .sq files in src/commonMain/sqldelight/. Define your tables with explicit SQL types. SQLDelight generates Kotlin data classes from these schemas — no manual mapping needed. The generated code is type-safe and null-safe, catching errors at compile time.

Step 3: Platform Drivers

SQLDelight uses platform-specific drivers: AndroidSqliteDriver for Android, NativeSqliteDriver for iOS, and JdbcSqliteDriver for Desktop/tests. Configure these in your Koin modules using expect/actual. The shared code never knows which driver it's using.

Want a detailed walkthrough with real code examples? Our KMP Mastery Course covers SQLDelight migration in Module 5, including schema versioning, complex queries, and testing strategies.

 
 
 

Recent Posts

See All
Compose Navigation in KMP: Patterns That Scale

Navigation in Compose Multiplatform is evolving fast. After trying Voyager, Decompose, and the official Compose Navigation, here are the patterns we settled on at MBS for our production apps. The Navi

 
 
 
Building Offline-First Apps with KMP

Users expect apps to work without internet. At MBS, every product we build is offline-first by default. Here are the architecture patterns and implementation strategies we use in Kotlin Multiplatform.

 
 
 
Koin vs Dagger in KMP: A Practical Comparison

Dependency injection is critical for maintainable KMP apps. We've used both Koin and Dagger/Hilt extensively in production. Here's when to choose each, with real examples from our apps. Koin: The KMP-

 
 
 

Comments


​Limited Time: Save 20% on All Courses - Enroll Today! | Use Coupon Code: MBSSALE20 at Checkout

bottom of page