Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite to Core Data Migration

I have a live app on App Store which uses SQLite as database, now with the next update I want to implement Core Data in App loading all data from .sqlite file without breaking the App. I have been reading tutorials but it didn’t help much. I don't know how to proceed. Please, point me in right direction.

like image 782
Arpit Dongre Avatar asked Mar 12 '23 11:03

Arpit Dongre


1 Answers

I think @SaintThread hit the main issue here. The reason for it is that Core Data is not a wrapper around SQLite-- it's a different API with different assumptions that just happens to use SQLite internally. Core Data doesn't attempt to be compatible with how you'd use SQLite if you were using SQLite on its own.

That said, if you still want to migrate, you'll have to design a Core Data model and then write fully custom code to migrate from your existing SQLite file to Core Data. Your code would need to read everything from SQLite, convert it to the new Core Data representation, save the changes, and then remove the existing SQLite files.

When removing the existing SQLite file, make sure to also remove the SQLite journal files (if any).

like image 182
Tom Harrington Avatar answered Mar 21 '23 19:03

Tom Harrington