0
votes

I've created a core data based application and users are able to backup and restore the database using dropbox.

Now I've changed the model (new version) adding a couple of attributes to an existing entity and implemented lightweight migration.

Migration works fine, my problem is when I restore the database created with previous model.

If I kill the app and relaunch the lightweight migration updates the database schema but I'd like to implement a way to force db schema update to new model without kill the app.

is there a way to do this?

Thanks, Max

1
You mean, you want to do that on the flight? - Nikita Pestrov
yes. I'd like to avoid user have to kill the app and restart. - masgar
So then you don't need to make those fetches - just store the variable. - Nikita Pestrov

1 Answers

0
votes

Automatic migration normally happens in addPersistentStoreWithType:configuration:URL:options:error:, typically called by the appDelegate.

Why don't you just remove the persistent store from your persistent store co-ordinator ( removePersistentStore:error: ) and re-add it; this should trigger lightweight migration