Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Error handling 房间迁移失败,没有错误_Error Handling_Kotlin_Android Room - Fatal编程技术网

Error handling 房间迁移失败,没有错误

Error handling 房间迁移失败,没有错误,error-handling,kotlin,android-room,Error Handling,Kotlin,Android Room,我正在使用Room,当我更改一个或多个实体时,它突然停止显示错误。例如,我在实体中添加了一个字段(vendor:String),它只清除所有数据,没有任何错误或建议。只是清除所有数据并停止工作。我不使用回退来破坏迁移 请帮帮我,我真的不知道如何避免这个。我的所有分支都在等待数据库同步 这是密码 @Database(entities = [(ServiceEntity::class), (ConfigEntity::class), (RequestEntity::class), (FaqEntit

我正在使用Room,当我更改一个或多个实体时,它突然停止显示错误。例如,我在实体中添加了一个字段(vendor:String),它只清除所有数据,没有任何错误或建议。只是清除所有数据并停止工作。我不使用回退来破坏迁移

请帮帮我,我真的不知道如何避免这个。我的所有分支都在等待数据库同步

这是密码

@Database(entities = [(ServiceEntity::class), (ConfigEntity::class), (RequestEntity::class), (FaqEntity::class),
    (SubscriptionEntity::class), (OrderEntity::class), (DeviceEntity::class), (ProblemEntity::class)], version = 5,
        exportSchema = true)
abstract class RoomAppDataSource: RoomDatabase() {
    abstract fun serviceDao(): ServiceDao
    abstract fun configDao(): ConfigDao
    abstract fun requestDao(): RequestDao
    abstract fun otherDao(): OtherDao
    abstract fun subscriptionsDao(): SubscriptionsDao
    abstract fun ordersDao(): OrdersDao

    companion object {
        private val TAG = RoomAppDataSource::class.java.simpleName

        private val Migration_4_5 = object: Migration(4, 5) {
            override fun migrate(database: SupportSQLiteDatabase) {
                database.execSQL("ALTER TABLE ${RoomContract.TABLE_SERVICES} ADD COLUMN vendor TEXT default '' NOT NULL")
            }
        }

        fun buildDataSource(context: Context): RoomAppDataSource = Room.databaseBuilder(
                context.applicationContext, RoomAppDataSource::class.java, RoomContract.DATABASE_APP)
                .addMigrations(Migration_4_5)
                .build()
    }
}

另外,如果我删除新行,效果会很好,但当我在任何实体中添加smth时,应用程序都会从教程页面开始,因为没有保存任何令牌。

找到答案。我不知道为什么,但room只是停止断言新版本的db或破坏性迁移,所以我只能在使用Dao funcs时看到错误。也许这会对某人有所帮助