# IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

- **ID:** `android/room-migration-not-found`
- **Domain:** android
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

Room database schema has changed (e.g., added column) but version number not incremented or migration not provided, causing integrity check failure.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Room 2.4.0 | active | — | — |
| Room 2.5.0 | active | — | — |
| Room 2.6.0 | active | — | — |

## Workarounds

1. **Increment database version and add migration: `@Database(entities = [User::class], version = 2)` and `val MIGRATION_1_2 = object : Migration(1, 2) { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL("ALTER TABLE User ADD COLUMN age INTEGER NOT NULL DEFAULT 0") } }`** (90% success)
   ```
   Increment database version and add migration: `@Database(entities = [User::class], version = 2)` and `val MIGRATION_1_2 = object : Migration(1, 2) { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL("ALTER TABLE User ADD COLUMN age INTEGER NOT NULL DEFAULT 0") } }`
   ```
2. **Use `autoMigrations` annotation: `@Database(entities = [User::class], version = 2, autoMigrations = [AutoMigration(from = 1, to = 2)])` for simple changes like adding columns with defaults.** (85% success)
   ```
   Use `autoMigrations` annotation: `@Database(entities = [User::class], version = 2, autoMigrations = [AutoMigration(from = 1, to = 2)])` for simple changes like adding columns with defaults.
   ```
3. **Export schema to JSON using `room.schemaLocation` in build.gradle, then use Room's automatic migration validator to detect issues.** (80% success)
   ```
   Export schema to JSON using `room.schemaLocation` in build.gradle, then use Room's automatic migration validator to detect issues.
   ```

## Dead Ends

- **Delete app data or uninstall app** — Loses all user data; only works for development, not production. (60% fail)
- **Set fallbackToDestructiveMigration() in Room database builder** — Destroys existing database on version mismatch, causing data loss; not suitable for production. (75% fail)
- **Ignore the error and continue** — App crashes on database access; cannot proceed without fixing migration. (95% fail)
