title: Realm model migration strategy
body: <p>I have run into a problem working with Realm migration blocks and the strategy for migrating realms.</p>
  
  <p>Given an object MyObject with a number of properties:</p>
  
  <ul>
  <li>In version 1 we have the property myProperty</li>
  <li>In version 2 we change the property to myPropertyMk2 </li>
  <li>In version 3 we change the property to myPropertyMk3</li>
  </ul>
  
  <p>Given following migration block:</p>
  
  <pre><code>    private class func getMigrationBlock(realmPath: String) -&gt; RLMMigrationBlock {
      return { migration, oldSchemaVersion in
          if (oldSchemaVersion == RLMNotVersioned) {
              NSLog("No database found when migrating.")
              return
          } else {
              NSLog("Migrating \(realmPath) from version \(oldSchemaVersion) to \(RealmMigrationHelper.CURRENT_DATABASE_VERSION)")
          }
  
          NSLog("Upgrading MyObject from version %d to %d", oldSchemaVersion, CURRENT_DATABASE_VERSION)
          if (oldSchemaVersion &lt; 2) {
              migration.enumerateObjects(MyObject.className(), block: {
                  oldObject, newObject in
                  newObject["myPropertyMk2"] = oldObject["myProperty"]
              })
          } 
          if (oldSchemaVersion &lt; 3) {
              migration.enumerateObjects(MyObject.className(), block: {
                  oldObject, newObject in
                  newObject["myPropertyMk3"] = oldObject["myPropertyMk2"]
              })
          } 
          NSLog("Migration complete.")
      }
  }
  </code></pre>
  
  <p>When I was version 2 of the DB this worked just fine (obviously without the <strong>oldSchemaVersion &lt; 3</strong> block), but when I introduced version 3 I started getting the problems because it does not recognise the <strong>newObject["myPropertyMk2"]</strong> in <strong>oldSchemaVersion &lt; 2</strong> block. If I change it to <strong>newObject["myPropertyMk3"]</strong> it works just fine.</p>
  
  <p>From reading the RLMMigration code this makes perfectly good sense as we work with the old schme and the new scheme, but based on the documentation on realm.io I do not think it makes sense. Then I would have expected it to be scheme less.</p>
  
  <p>I have an idea about making a scheme less migration within the block by simply using a dictionary and then finally apply this dictionary to the <strong>newObject</strong>.</p>
  
  <p>Are there any thoughts on the migration strategy of realms that deals with this? It is mentioned on realms website, but only very briefly.</p>
  
  <p>Thank you :)</p>