从必需变量到可为空的领域迁移 [英] Realm migration from a required variable to nullable
本文介绍了从必需变量到可为空的领域迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从必需变量到可空变量的领域迁移
Realm migration from a required variable to nullable
我有一个变量,它是我以前版本的领域中的必需字段.但是对于较新的版本,我希望它不是必需的,而是可以为空的.我如何通过领域迁移来做到这一点?
I had a variable which was a REQUIRED field in my previous version of realm. But for the newer version i want it to be not required but a nullable one. How do i do it through realm migration?
推荐答案
您可以查看 migrationExample 由 Realm 团队提供
You can check the example in migrationExample provided by Realm team
if (oldVersion == 2) {
RealmObjectSchema personSchema = schema.get("ClassName");
personSchema.setNullable("nullableFielName", true);
}
如果您已经与 Realm Object Server 同步,请检查:https://realm.io/docs/java/latest/#syncing-migrations
If you have already synced with Realm Object Server, please check this: https://realm.io/docs/java/latest/#syncing-migrations
这篇关于从必需变量到可为空的领域迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文