java.lang.IllegalStateException: Migration didn't properly handle:
See original GitHub issueRoom Version: 2.2.5 Roomigrant Version: 0.34
I just removed a single property from my entity class and then got this error message:
Before
@Parcelize
@TypeConverters(Converters::class)
@Entity(tableName = "customers")
data class EntityCustomer(
@PrimaryKey
@ColumnInfo(name = "uuid")
val uuid: String = UUID.randomUUID().toString(),
@ColumnInfo(name = "priority")
var priority: Int = 1,
@ColumnInfo(name = "is_manually_scheduled")
val isManuallyScheduled: Boolean = false,
@ColumnInfo(name = "is_deleted")
val isDeleted: Boolean = false,
@ColumnInfo(name = "owner")
val owner: String = "undefined"
) : Parcelable
After
@Parcelize
@TypeConverters(Converters::class)
@Entity(tableName = "customers")
data class EntityCustomer(
@PrimaryKey
@ColumnInfo(name = "uuid")
val uuid: String = UUID.randomUUID().toString(),
@ColumnInfo(name = "priority")
var priority: Int = 1,
@ColumnInfo(name = "is_manually_scheduled")
val isManuallyScheduled: Boolean = false,
@ColumnInfo(name = "is_deleted")
val isDeleted: Boolean = false,
) : Parcelable
2021-04-06 13:04:14.353 6601-6601/app.planner.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: app.planner.debug, PID: 6601
java.lang.IllegalStateException: Migration didn't properly handle: customers(app.planner.core.domain.entity.EntityCustomer).
Expected:
TableInfo{name='customers', columns={is_deleted=Column{name='is_deleted', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, priority=Column{name='priority', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, uuid=Column{name='uuid', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=1, defaultValue='null'}, is_manually_scheduled=Column{name='is_manually_scheduled', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
Found:
TableInfo{name='customers', columns={owner=Column{name='owner', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, is_deleted=Column{name='is_deleted', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, is_manually_scheduled=Column{name='is_manually_scheduled', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, priority=Column{name='priority', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, uuid=Column{name='uuid', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=1, defaultValue='null'}}, foreignKeys=[], indices=[]}
at androidx.room.RoomOpenHelper.onUpgrade(RoomOpenHelper.java:103)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onUpgrade(FrameworkSQLiteOpenHelper.java:177)
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.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:145)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:106)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:476)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:281)
at androidx.room.RoomDatabase.query(RoomDatabase.java:324)
at androidx.room.util.DBUtil.query(DBUtil.java:83)
at app.planner.core.data.database.dao.ContactRoomDao_Impl$4.call(ContactRoomDao_Impl.java:138)
at app.planner.core.data.database.dao.ContactRoomDao_Impl$4.call(ContactRoomDao_Impl.java:135)
at androidx.room.CoroutinesRoom$Companion$createFlow$1$1.invokeSuspend(CoroutinesRoom.kt:81)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Im planning to go production soon but I am not sure about using this library, especially if I’m making bigger changes to the schema. I don’t want the app to crash on startup.
Issue Analytics
- State:
- Created 2 years ago
- Comments:25 (12 by maintainers)
Top Results From Across the Web
Room Database Migration doesnt properly handle ALTER ...
The error message is hard to parse, but there's a difference: TableInfo{name='user', columns={name=Column{name='name', type='TEXT', ...
Read more >Migration didn't properly handle <table_name> #16 - GitHub
The problem is, every time I try to run the app in an emulator I am getting the Migration failed error. Here is...
Read more >Auto migration error when object is embedded [193798291]
... PID: 29544 java.lang.IllegalStateException: Migration didn't properly handle: StaffScheduleAssignment(ch.lamelcolor.lafipla.model.
Read more >Migrating Room databases | Android Developers
Gracefully handle missing migration paths. If Room cannot find a migration path for upgrading an existing database on a device to the current...
Read more >Understanding migrations with Room | by Florina Muntenescu
If you're using Room to handle your database operations, migrations are as ... Room will throw an IllegalStateException if you don't provide a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

ok, I’ll add
@itsandreramon hello. thanks for finding a bug. I’ll take a look as soon as I can. PS: if you find fix yourself - please paste it here