{
  "id": "android/illegalstateexception-room-migration-failed",
  "signature": "IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the migration(s).",
  "signature_zh": "IllegalStateException: Room 无法验证数据完整性。看起来您更改了架构但忘记更新迁移。",
  "regex": "IllegalStateException: Room cannot verify the data integrity.*",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Database schema version mismatch: the code expects a newer schema than the installed database, and no migration path is provided.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库架构版本不匹配：代码期望的架构比已安装的数据库新，且未提供迁移路径。",
  "versions": [
    {
      "version": "Room 2.5.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 13 (API 33)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 14 (API 34)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Uninstalling the app and reinstalling works temporarily but loses user data, unacceptable for production.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting fallbackToDestructiveMigration() in the database builder causes data loss on every schema change, which is destructive.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manually altering the database version number without providing a migration leads to the same error.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.9,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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).",
      "success_rate": 0.8,
      "how": "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).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Export the schema JSON files by setting room.schemaLocation in build.gradle and use them to generate migration test cases.",
      "success_rate": 0.75,
      "how": "Export the schema JSON files by setting room.schemaLocation in build.gradle and use them to generate migration test cases.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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.",
    "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).",
    "Export the schema JSON files by setting room.schemaLocation in build.gradle and use them to generate migration test cases."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/training/data-storage/room/migrating",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-09-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}