我是 android 房间图书馆的新手。我需要将 Not Null 列迁移到 Null,但房间迁移只允许在 ALTER 表查询中添加或重命名。如何执行列迁移查询?
@Entity(tableName = "vehicle_detail")
data class VehicleDetailsEntity(
@PrimaryKey(autoGenerate = true)
val vehicleClientId: Long = 0,
val vehicleId: String,
val updatedOn: Date,
val updatedBy: String
)
Run Code Online (Sandbox Code Playgroud)
我需要将表结构更改为
@Entity(tableName = "vehicle_detail")
data class VehicleDetailsEntity(
@PrimaryKey(autoGenerate = true)
val vehicleClientId: Long = 0,
val vehicleId: String,
val updatedOn: Date?,
val updatedBy: String?
)
Run Code Online (Sandbox Code Playgroud)
java.lang.IllegalStateException: Room 无法验证数据完整性。看起来您已更改架构但忘记更新版本号。您可以通过增加版本号来简单地解决此问题。