I am attempting to complete my first iOS app and could use some help in efficiently merging two persistent stores. By "efficiently", I mean dealing with adds and changes without having to manually do a record-by-record analysis to end up with a single store with no duplicates. I foresee continual updates to the database we supply the user and will need to update their database without destroying any new records they may have added to database we originally supplied them.
Currently, at start-up the app checks for a persistent store in the user's Documents directory - call it "Main.sqlite". If it doesn't find the file, then it copies SeedData.sqlite from the app bundle to Main.sqlite in the user's Documents directory using NSFileManager method, -copyItemAtPath:toPath:error:.
Next, if it DOES find Main.sqlite in the Documents directory, then I would like to merge SeedData.sqlite into Main.sqlite. Both stores have exactly the same structures. The merge criteria would be: SeedData record MATCHES Main record - take no action. SeedData record NOT FOUND in Main - add SeedData record to Main.
The number of records in each store would be on the order of a few thousand.
I know Sunny dealt with a more complicated scenario two years ago. What is an efficient way to Merge two iOS Core Data Persistent Stores?
I'm wondering if anything has changed in the last 2 years that would make the solution even easier and what, if any, impact the change in iOS 7 to the default journal mode from rollback journaling to Write Ahead Logging has on the solution.
I've read Marcus Zarra's blog and Ray Wenderlich's guys say that migration is for moving a database to a new structure and not for moving new data between two identical structures - although it seems as though Sunny disagrees.
What's the best approach?