迁移多个领域 - 领域版本大于模式版本异常 [英] Migrating multiple realms - Realm Version Greater Than Schema Version exception
本文介绍了迁移多个领域 - 领域版本大于模式版本异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么会抛出此异常(当我尝试迁移多个域时)?
Why this exception is thrown (when I'm trying to migrate multiple realms)?
bool ObjectStore::is_schema_at_version(Group *group, uint64_t version) {
uint64_t old_version = get_schema_version(group);
if (old_version > version && old_version != NotVersioned) {
throw ObjectStoreException(ObjectStoreException::Kind::RealmVersionGreaterThanSchemaVersion,
{{"old_version", to_string(old_version)}, {"new_version", to_string(version)}});
}
return old_version != version;
}
推荐答案
首先我需要以正确的方式实例化realmconfig。
First of all I needed to instantiate realmconfig in the right way.
RLMRealmConfiguration *someOtherConfig = [[RLMRealmConfiguration defaultConfiguration] copy];
而不是:
RLMRealmConfiguration *someOtherConfig = [[RLMRealmConfiguration alloc] init];
我需要删除额外的schemaVersion配置和冗余迁移块:
And I needed to remove the additional schemaVersion config and redundant migrationblocks:
config.schemaVersion = migrationVersion;
在执行实际迁移之前:
[RLMRealm migrateRealm:someOtherConfig];
这篇关于迁移多个领域 - 领域版本大于模式版本异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文