Roomigrant: java.lang.IllegalStateException: Migration didn't properly handle:
Room 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (12 by maintainers)
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