Reputation: 4886
Within Realm how do you perform a Migration that adds the Primary Key
function to a property, when using Swift?
Upvotes: 0
Views: 847
Reputation: 15991
This was previously answered for Realm Objective-C here: https://stackoverflow.com/a/29417579/599344
Essentially, if you're promoting a property to a primary key, and the property already has a unique value per object, you don't need to do anything special aside from running a normal migration.
If your new primary key property does have duplicate entries, then you'll need to change their values to something unique inside the migration block.
Upvotes: 1