Delete a property that was added in a migration


#1

Imagine this scenario:
Schema #0 defines

class User: Object {
   @objc dynamic var firstName: String
   @objc dynamic var lastName: String
}

Schema #1 introduces fullName by merging firstName and LastName

class User: Object {
   @objc dynamic var fullName: String
}

if oldSchemaVersion < 1 {
   migration.enumerateObjects(ofType: RealmUser.className()) { oldObject, newObject in
        guard let newObject = newObject, let oldObject = oldObject else { return }
        newObject["fullName"] = "\(oldObject["firstName"]) \(oldObject["lastName"])"
   }
}

Then Schema #2 changes fullName to nickName

class User: Object {
   @objc dynamic var nickName: String
}

if oldSchemaVersion < 2 {
   migration.enumerateObjects(ofType: RealmUser.className()) { oldObject, newObject in
        guard let newObject = newObject, let oldObject = oldObject else { return }
        newObject["nickName"] = "@\(oldObject["fullName"])"
   }
}

For a user that updates my app constantly that should work fine. But if a user jumps from schema #0 to schema #2 the app will crash trying to run the migration for schema #1 because newObject["fullName"] no longer exists in the new schema.

So my question is, When I delete a realm property do I need to go and delete code in every migration where that property is accessed? It doesn’t feels right for big apps. Am I missing something?

Thanks!