android机房迁移指标变化

旧实体如下:

@Entity(tableName = "d_course",
    foreignKeys = @ForeignKey(entity = DUser.class, parentColumns = "id", childColumns = "studio"),
    indices = @Index(value = "studio"))

新的实体如下:

@Entity(tableName = "d_course",
    foreignKeys = @ForeignKey(entity = DUser.class, parentColumns = "id", childColumns = "studio"),
    indices = @Index(value = {"id", "studio"}))

我该怎么做才能迁移此索引更改.

最佳答案
尝试指定此索引在迁移中的更改,例如(Kotlin):

val MIGRATION_1_2 = object : Migration(1, 2) {
    override fun migrate(database : SupportSQLiteDatabase) {
        ...
        database.execSQL("CREATE INDEX index_d_course_id_studio ON  d_course(id, studio)")
    }
}

转载注明原文:android机房迁移指标变化 - 代码日志