I\'m using realm.io in a swift app. This is the first time I\'ve had to run a migration since I have an app in production. I changed one of the models and added a couple of
I found this to work best in a View Controller:
let migrationBlock: MigrationBlock = { migration, oldSchemaVersion in
//Leave the block empty
}
lazy var realm:Realm = {
Realm.Configuration.defaultConfiguration = Realm.Configuration(schemaVersion: 1, migrationBlock: migrationBlock)
return try! Realm()
}()
In other words, move the configuration assignment into the block so it doesn't get executed too late.