【发布时间】:2019-02-07 13:11:48
【问题描述】:
我想将一个新架构添加到我的数据库中,并引用另一个新架构。
以下是模型:
open class Code(
var name: String? = null,
var code: String? = null
) : RealmObject()
open class Foo(
var codes: RealmList<Code> = RealmList()
) : RealmObject()
还有迁移:
val codeSchema = schema.create("Code")
.addField("name", String::class.java)
.addField("code", String::class.java)
schema.create("Foo")
.addRealmObjectField("codes", codeSchema)
但这会崩溃并出现以下错误:
io.realm.exceptions.RealmMigrationNeededException: Migration is required due to the following errors:
- Property 'Foo.codes' has been changed from '<Code>' to 'array<Code>'.
因为这两个都是新的模型,我不知道为什么它告诉我某些东西“已经改变了”。
如何正确添加这两个模型?
【问题讨论】:
标签: android kotlin realm realm-migration