旧实体如下:
@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"}))
如何迁移此指数更改。
答案 0 :(得分:3)
尝试在迁移中指定此索引更改,例如(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)")
}
}