room-sqldelight-migrator

Authors and validates Room and SQLDelight database migrations on Android and KMP.

Updated Jan 2, 2024
One-click install
npx skills add https://github.com/Mithrandir21/game-deals-app --skill room-sqldelight-migrator-mithrandir21
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: room-sqldelight-migrator
Source: https://github.com/Mithrandir21/game-deals-app/tree/main/.claude/skills/room-sqldelight-migrator
Command: npx skills add https://github.com/Mithrandir21/game-deals-app --skill room-sqldelight-migrator-mithrandir21

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database migrations run against real user data in production, and a single bad migration can corrupt or wipe that data. This Skill enforces a disciplined process for writing, testing, and validating Room and SQLDelight schema migrations so upgrades ship safely. ## Core Features & Use Cases - Migration Authoring: Writes version-bumped Room Migration classes or SQLDelight .sqm files, including manual table-rebuild patterns for column type changes, renames, and constraint additions. - Migration Testing: Generates MigrationTestHelper instrumentation tests for Room and schema-verification guidance for SQLDelight to prove data survives the upgrade. - Query Optimization: Diagnoses slow queries with EXPLAIN QUERY PLAN, adds targeted indexes, fixes N+1 patterns, and integrates Paging 3 for large result sets. - Use Case: You need to add a non-null email column to an existing user table in a shipping Room database. The Skill produces the version bump, the ALTER TABLE migration with a safe default, the exported schema JSON, and an instrumentation test validating the 6-to-7 upgrade path. ## Quick Start Ask the assistant to write and test a Room migration that adds a new column to an existing table in your Android database.

Frequently Asked Questions about room-sqldelight-migrator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Room database migration in Android?▼

Bump the `@Database` version, enable `exportSchema = true`, and create a `Migration(oldVersion, newVersion)` object executing the required SQL such as `ALTER TABLE`. Register it with `addMigrations()` on the database builder and commit the exported schema JSON.

How do I test a Room migration before release?▼

Use `MigrationTestHelper` in an instrumentation test: create the database at the old version, insert representative data, then call `runMigrationsAndValidate` with your migration. Assert the migrated rows contain the expected values.

How do SQLDelight migrations work?▼

SQLDelight migrations are `.sqm` files named after the old version, placed in the migrations directory, each bringing the schema from version N to N+1. The build automatically verifies that applying the migrations reproduces the current schema, failing the build on mismatch.

Why does my Room migration crash with schema mismatch on upgrade?▼

This usually happens when the schema changed without bumping the database version, or a migration path is missing for the user's installed version. Adding a `NOT NULL` column without a `DEFAULT` on an existing table also crashes on existing rows.

Can I edit a Room migration that is already shipped?▼

No. Users on older versions travel through every shipped migration, so editing one breaks their upgrade path and invalidates your tests. Always add a new migration instead of modifying a released one.

How do I fix slow Room queries and N+1 problems?▼

Run `EXPLAIN QUERY PLAN` on the slow query to check index usage, then add `@Entity` indices on columns used in `WHERE` and `ORDER BY`. Replace per-item `getById` loops with a single `IN (...)` query and use Paging 3 for large result sets.