# IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the migration(s).

- **ID:** `android/illegalstateexception-room-migration-failed`
- **Domain:** android
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Database schema version mismatch: the code expects a newer schema than the installed database, and no migration path is provided.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Room 2.5.2 | active | — | — |
| Room 2.6.0 | active | — | — |
| Android 13 (API 33) | active | — | — |
| Android 14 (API 34) | active | — | — |

## Workarounds

1. **Add a Room migration from the old version to the new version. Example: Room.databaseBuilder(context, AppDatabase.class, "my-db").addMigrations(MIGRATION_1_2).build(); where MIGRATION_1_2 is a Migration object that executes ALTER TABLE statements.** (90% success)
   ```
   Add a Room migration from the old version to the new version. Example: Room.databaseBuilder(context, AppDatabase.class, "my-db").addMigrations(MIGRATION_1_2).build(); where MIGRATION_1_2 is a Migration object that executes ALTER TABLE statements.
   ```
2. **Use AutoMigration with @Database(version = 2, autoMigrations = {@AutoMigration(from = 1, to = 2)}) if schema changes are simple (e.g., adding a column with a default value).** (80% success)
   ```
   Use AutoMigration with @Database(version = 2, autoMigrations = {@AutoMigration(from = 1, to = 2)}) if schema changes are simple (e.g., adding a column with a default value).
   ```
3. **Export the schema JSON files by setting room.schemaLocation in build.gradle and use them to generate migration test cases.** (75% success)
   ```
   Export the schema JSON files by setting room.schemaLocation in build.gradle and use them to generate migration test cases.
   ```

## Dead Ends

- **** — Uninstalling the app and reinstalling works temporarily but loses user data, unacceptable for production. (90% fail)
- **** — Setting fallbackToDestructiveMigration() in the database builder causes data loss on every schema change, which is destructive. (80% fail)
- **** — Manually altering the database version number without providing a migration leads to the same error. (95% fail)
