iOS RealmSwift DB Migration Primary Keys

85 views Asked by At

I was migrating from Obj-C realm to RealmSwift. I have some changes in primary keys and data types I used following code,

migrationBlock: { migration, oldSchemaVersion in
                if (oldSchemaVersion < 1) {
                    migration.enumerateObjects(ofType: Countries.className()) { oldObject, newObject in
                        newObject!["Country_Code"] = oldObject!["Country_Code"]
                    }
                }

Is there any way to dynamically migrate the properties without hard coding each property.

We have tried using nested migration.

0

There are 0 answers