0

I have live application on the app store. It uses SQLite data storage and ugly methods that save and get data form it. I have replaced the data model with core data. So right now I have one table that contains favorites list. I suppose user will lose their favorites data, and the second problem will be that previous SQLite data base will be in the app.

What's the best way to migrate that data to new data base. So code was ugly, I have started to write new project. It means that there will not be any SQLite data base as before with the same name, just new Core Data db. How usually we need to solve this problem.

I think I can add a method in app delegate that will check if data base with name in the application I will try to retrieve all data from that storage and convert it to the Core Data entities. Then when data will be converted with success, I will drop that database. When I will if all my active users will have this update. I will remove this feature from app delegate because all will up to date. Does it make sense?

2
  • is your table dataStructure and relationship in tables going to be same or different? Commented Feb 13, 2015 at 14:52
  • @Shashi3456643, fortunately there are no relationships, but I think the structure of data model will be the same. But in this case I will use entity for favorites list. I even did some not maybe great things, So my Favorite entity has NSMutableDictionary as value that contains all information about entry. For current small structure it's ok. Commented Feb 13, 2015 at 15:55

1 Answer 1

1

Your approach is correct. In the new app version, check if there is an up-do-date Core Data persistent store, if not, read the old data, copy it to Core Data, delete the old sqlite file.

You can leave that code in there for a long time - it just won't run if there already is a valid Core Data installation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.