【发布时间】:2021-09-02 09:30:22
【问题描述】:
我有一个数据库迁移:
val MIGRATION_8_9 = object : Migration(8, 9) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE RideEntity RENAME frontVideoPresent TO frontVideoState")
database.execSQL("ALTER TABLE RideEntity RENAME rearVideoPresent TO rearVideoState")
}
}
在本地三星手机上测试此迁移时,它运行良好。在 craslytics 的帮助下,我看到了这个崩溃:
Fatal Exception: java.lang.RuntimeException
Exception while computing database live data.
Caused by android.database.sqlite.SQLiteException
near "frontVideoPresent": syntax error (Sqlite code 1 SQLITE_ERROR): , while
compiling: ALTER TABLE RideEntity RENAME frontVideoPresent TO frontVideoState, (OS
error - 11:Try again)
这发生在华为 Mate 20 手机上。如何更好地理解这次崩溃?这与操作系统有关吗? 我现在无法删除重命名,因为许多用户更新了该列重命名的应用程序,但使用华为手机的用户可能会遭受此崩溃。 我愿意接受您的建议...
【问题讨论】:
标签: android android-room database-migration