【问题标题】:Migrating multiple realms - Realm Version Greater Than Schema Version exception迁移多个领域 - 领域版本大于架构版本异常
【发布时间】:2015-11-20 14:14:32
【问题描述】:

为什么会抛出此异常(当我尝试迁移多个领域时)?

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;
}

【问题讨论】:

    标签: ios realm


    【解决方案1】:

    首先,我需要以正确的方式实例化 realmconfig。

    RLMRealmConfiguration *someOtherConfig = [[RLMRealmConfiguration defaultConfiguration] copy];
    

    代替:

    RLMRealmConfiguration *someOtherConfig = [[RLMRealmConfiguration alloc] init];
    

    我需要删除额外的 schemaVersion 配置和冗余迁移块:

    config.schemaVersion = migrationVersion;
    

    在执行实际迁移之前:

    [RLMRealm migrateRealm:someOtherConfig];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-09
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 2019-08-22
      • 1970-01-01
      相关资源
      最近更新 更多