0
votes

I accidentally managed to lose the old version of our data model, and now the automatic lightweight migration doesn't work (obviously). I managed to let Core Data delete the old store if this problem occurs, but i obviously would want to not lose the old data. So how can i manually migrate? On startup, i just get an error that the store coordinator has no persistent stores (error 134140).

I have already tried making a new model version that matches the old one (It actually states the old, used model in the error message), but somehow this doesn't work either. It used to work before, but apparently i just messed up saving the model verison of the current app store version.

Edit: I just thought of possibly another way (No idea why i didn't think of this before): Because core data is backed by an SQLite database, can't i get the information i need (That is, 4 rows from the database, then i can repopulate the rest of it myself) directly from it? If so, what could i use to do this?

1
Your current question cannot be answered. You need to provide more details. - Security Hound
What additional information would you need? I have a database without the old model, and when updating the app it can't migrate the data to the new model. - Erik S
I just thought of possibly another way (No idea why i didn't think of this before): Because core data is backed by an SQLite database, can't i get the information i need (That is, 4 rows from the database, then i can repopulate the rest of it myself) directly from it? If so, what could i use to do this? - Erik S

1 Answers

0
votes

I'm not exactly sure how it's done, but the model is versioned, perhaps using an GUID or a cryptographic hash of the model file. So you need exactly the same file that the model was created with.

Or put another way, you need to be using version control.

I guess it should be theoretically be possible to exactly recreate your model, but I don't know of a way of doing it.