Reputation: 31
I’ve an app on the App Store and I’ve noticed that in rare circumstances, when I update the fields of an object in CoreData, a new NSManagedObject is created with the new property value and all the relationships set to null.
So, I’ve an inconsistency in the database because there could be the possibility to have at the same time the old object and a duplicated one with null relationship and the updated property value.
I’m studying the problem and the solution could be to add a unique constraint (the objects have an id field which should be unique). The problem is that this migration causes the crash if duplicated objects are in the database. On a fresh install, instead, all works correctly. How can I manage the migration of the users with duplicate items?
Upvotes: 1
Views: 194