title: Why does a Realm's schema version reset to 0 after a migration?
body: <p>I'm trying to perform a Realm migration with the following code:</p>
  
  <pre><code>let version = try! schemaVersionAtURL(Realm.Configuration.defaultConfiguration.fileURL!)
  let config = Realm.Configuration(
              schemaVersion: version + 1,
              migrationBlock: { migration, oldSchemaVersion in
                  if oldSchemaVersion &lt; 1 {
                      migration.enumerateObjects(ofType: MyObject.className()) { oldObject, newObject in
                          // Here I transfer existing data to new properties
                      }
                  }
          })
  Realm.Configuration.defaultConfiguration = config
  let _ = try! Realm()
  </code></pre>
  
  <p>The migration seems to work fine, but the next time the app is relaunched, both the current and old schema versions are 0, despite having been set to 1 by the migration that occurred during the first launch.</p>
  
  <p>But the migration is done, so the <code>if</code> condition is true, and the app crashes with a Realm exception caused by trying to perform the migration again.</p>
  
  <p>Can anyone help me understand what I'm missing? If the configuration is setting the schema version to 1 during the migration, why is it 0 the next time the app is relaunched?</p>