iPhone application update (using Core Data on Sqlite)

Posted by owen on Stack Overflow See other posts from Stack Overflow or by owen
Published on 2010-04-27T11:42:13Z Indexed on 2010/04/27 13:23 UTC
Read the original article Hit count: 299

Filed under:
|
|

I have an app which is using Core Data on Sqlite, Now I have a update which has some DB structure changes say adding a new table

I know when an app get updated, it updates the app binary only, nothing on document directory will be changed.

When the app gets updated and launchs at the first time and run

[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

It will find the difference between the data model and DB structure in Sqlite and will throw an exception and quit.

Error: "The model used to open the store is incompatible with the one used to create the store"

So, can anyone here give me some idea how to update an app when there is a DB structure change?

I think we can run a DB script to create that new table when it launchs the update at the first time.

But if there are other changes like changing the type of some fields or deleting some fields, and we need to migrate the old data, this is really a headache. In this case, Is the only way to do is creating a new app?

Is there anyone tried something similar like this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data