Spaceghost
Spaceghost

Reputation: 45

perform realm migration for multiple .realm files

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?

Upvotes: 1

Views: 694

Answers (1)

jpsim
jpsim

Reputation: 14409

+[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];

Upvotes: 2

Related Questions