room-schema-governance

Enforces Room database version increments and migration rules when entities change.

Updated May 21, 2025
One-click install
npx skills add https://github.com/albertmartorell1975/MeteoMartoCompose --skill room-schema-governance-albertmartorell1975
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: room-schema-governance
Source: https://github.com/albertmartorell1975/MeteoMartoCompose/tree/main/.agents/skills/room-schema-governance
Command: npx skills add https://github.com/albertmartorell1975/MeteoMartoCompose --skill room-schema-governance-albertmartorell1975

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Room database schema changes without version bumps or proper migrations cause IllegalStateException crashes and data loss. This Skill enforces consistent schema evolution rules so every @Entity modification is paired with a correct @Database version increment and an appropriate migration strategy. ## Core Features & Use Cases - Automatic Version Increment: Detects changes to @Entity classes and increments the version number in the @Database class by exactly one. - Migration Protocol: Applies .fallbackToDestructiveMigration() during development and proposes manual Migration implementations for stable or release branches. - Build Verification: Runs ./gradlew :app:assembleDebug to trigger the Room annotation processor and validates exportSchema output. - Use Case: When adding a new FavoriteCity entity to an Android app, the Skill updates the entities array with trailing commas, bumps the database version, and verifies the schema compiles cleanly. ## Quick Start Ask the agent to add a new Room entity or modify an existing one and have it update the database version and verify the schema with a clean build.

Frequently Asked Questions about room-schema-governance

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

FAQPage Schema
How do I update the Room database version when adding an entity?▼

Locate the abstract class annotated with @Database and increment its version number by exactly one. Add the new entity class to the entities array with trailing commas, then run a clean build to verify the Room annotation processor output.

How to handle Room migrations during Android development?▼

During development, use .fallbackToDestructiveMigration() in the Room database builder to allow rapid schema changes without writing migration scripts. For stable or release branches, implement a manual Migration class instead to preserve user data.

Why does Room throw IllegalStateException after schema changes?▼

Room throws IllegalStateException when the database version does not match the schema hash of the entities, typically because the version was not incremented after modifying an @Entity. Incrementing the version and providing a migration or destructive fallback resolves it.

Does Room exportSchema need to be configured for migrations?▼

Yes, when exportSchema is set to true, Room generates a schema JSON file for each version that should be tracked in version control. These files enable migration testing and document the schema history.

When should I avoid fallbackToDestructiveMigration in Room?▼

Avoid destructive fallback on stable or release branches because it deletes all existing user data when the schema changes. Use it only during active development, and write explicit Migration implementations before shipping to production.