【发布时间】:2018-09-09 09:54:32
【问题描述】:
我正在使用房间数据库我有一个表格,我忘记在其中添加onDelete = CASCADE
以前的版本
@Entity(indices = {@Index(value = {"info_id"})}, foreignKeys = @ForeignKey(entity = StudentClass.class, parentColumns = "id", childColumns = "info_id"))
我现在想要什么
@Entity(indices = {@Index(value = {"info_id"})}, foreignKeys = @ForeignKey(entity = StudentClass.class, parentColumns = "id", childColumns = "info_id", onDelete = CASCADE))
我正在尝试迁移数据库
static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("What should I do here to add onDelete = CASCADE");
}
};
【问题讨论】:
标签: android sqlite android-room