I am experiencing a crash in my Android application due to an issue with Room database migration. The crash log indicates that the migration didn’t properly handle the BROADCAST_LIST table. Below is the relevant portion of the crash log:
java.lang.IllegalStateException: Migration didn't properly handle: BROADCAST_LIST(com.enjayworld.enjaycrm.broadcastAutomation.data.model.PhoneNumber).
Expected:
TableInfo{name='BROADCAST_LIST', columns={date=Column{name='date', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='CURRENT_TIMESTAMP'}, id=Column{name='id', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=1, defaultValue='undefined'}, verification_status=Column{name='verification_status', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='undefined'}, phone=Column{name='phone', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='undefined'}, isWhatsApp=Column{name='isWhatsApp', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='undefined'}, file_name=Column{name='file_name', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='undefined'}}, foreignKeys=[], indices=[]}
Found:
TableInfo{name='BROADCAST_LIST', columns={}, foreignKeys=[], indices=[]}
at androidx.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.kt:93)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onUpgrade(FrameworkSQLiteOpenHelper.kt:253)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:416)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableOrReadableDatabase(FrameworkSQLiteOpenHelper.kt:232)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.innerGetDatabase(FrameworkSQLiteOpenHelper.kt:190)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getSupportDatabase(FrameworkSQLiteOpenHelper.kt:151)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.kt:104)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.kt:632)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.kt:451)
Has anyone encountered a similar issue or have any advice on how to resolve this migration problem? Any help would be greatly appreciated!
I expected the migration script to properly update the schema of the BROADCAST_LIST table, so that the columns and their definitions match what Room expects. This would prevent the application from crashing and allow it to access and manipulate the data as intended.