Nick Harris

CoreData Migration Testing

Testing CoreData Migration is usually my last step before submitting to the AppStore.  Typically I label my last successful released version in Mercurial, then when I’m ready to submit again I pull that source code into a different directory and run it in the debugger.  This creates my old sqlite database.  Then I can run the new code and make sure the migration is successful.

I ran into an issue yesterday though with my latest release where I didn’t have the right version labeled in Mercurial… so I wasn’t sure how to get a copy of the old sqlite database.  After an admittedly lazy tweet, @ideal1st put me on the right track – “Download a datastore from your device, pop in simulator and run mapping model on it“.  But I wasn’t quite sure how to get at the Application directory.  A quick Google search later I found iPhone Backup Extractor.  From there it was easy…

1. Download the existing app from the app store and run it
2. Take a backup in iTunes
3. Use iPhone Backup Extractor to grab the Documents and Library directories of my app which has my sqlite database file
4. Run the new code in the iPhone Simulator
5. Navigate to the Documents directory of the app in the simulator and replace its contents from what was in the backup
6. Run the new code again and verify the migration

Glad I did too.  I had an issue where an attribute was getting an invalid type, but a quick look with SQLite Database Browser helped clear that up.

Hopefully that helps someone else.  I’d love to hear better suggestions as well!

Written by Nick Harris

June 14, 2011 at 6:56 pm

Posted in Uncategorized

%d bloggers like this: