我有多个领域文件(每个用户登录一次我的应用程序),我需要为文件系统中的每个领域文件运行迁移
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];
如何为每个文件系统数据库执行域迁移,而不仅仅是默认域文件?
答案 0 :(得分:2)
+[RLMRealm migrateRealm:]
在配置指定的路径上执行Realm的迁移:
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.schemaVersion = 1;
config.migrationBlock = ...;
config.path = @"path 1";
[RLMRealm migrateRealm:config];
config.path = @"path 2";
[RLMRealm migrateRealm:config];