对多个.realm文件执行领域迁移 [英] perform realm migration for multiple .realm files

查看:134
本文介绍了对多个.realm文件执行领域迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个领域文件(每个用户登录到我的应用程序一个),并且我需要为文件系统中的每个领域文件运行迁移

i have multiple realm files, (one per user logged into my app) and i need to run a migration for each realm file in the file system

      RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];

  config.schemaVersion = 1;
  config.migrationBlock = ^(RLMMigration *migration, uint64_t oldSchemaVersion) {

    if (oldSchemaVersion < 1) {
    //do the same changes for all file.realm in the filesystem 
    }
  };


  [RLMRealmConfiguration setDefaultConfiguration:config];

  [RLMRealm defaultRealm];

如何对每个文件系统数据库执行领域迁移,而不仅对默认领域文件执行领域迁移?

how can perform a realm migration for each of the filesystem databases and not only for the default realm file?

推荐答案

+[RLMRealm migrateRealm:] performs the migration for the Realm at the path specified by the configuration:

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.schemaVersion = 1;
config.migrationBlock = ...;
config.path = @"path 1";
[RLMRealm migrateRealm:config];
config.path = @"path 2";
[RLMRealm migrateRealm:config];

这篇关于对多个.realm文件执行领域迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆