Reputation: 13286
I'm receiving crash reports like the following:
Migration is required due to the following errors: - Property 'UserProfile.interfaceLanguage' has been added.
I understand how to perform a migration in general, but I don't know what is required when you add a property. interfaceLanguage
is not strictly required for the app to work and it will be fetched from the server eventually. I suppose I could set it to some value during the migration, but that seems a bit pointless.
Moreover, I thought this case was handled by default: https://realm.io/docs/swift/latest/#migrations
if (oldSchemaVersion < 1) { // Nothing to do! // Realm will automatically detect new properties and removed properties // And will update the schema on disk automatically }
Upvotes: 1
Views: 1342
Reputation: 54805
You don't have to do anything in your migration block when adding properties, Realm will do the migration automatically. All you have to do is increase your schema version by one and increase the number (1) in if (oldSchemaVersion < 1)
as well.
Upvotes: 3