Update core data database in app update without migrating - iphone

I have an application in iTunes app store using core data. Currently I'm developing a new version that has a new core data model. I do not want to migrate the data when updating. I just want to remove the old one and in with the new.
Whats the best way to handle this? My current (temporary?) solution is to change the path of the sqlite file which leaves the old database in the app.
Is there a migration option to remove the store if it can not be migrated, or some other solution?

I would probably check for the existence of the original database using NSFileManager and delete/remove it if found. The best place to do this is probably when you create the persistent store that Core Data uses.

Related

Core Data Update in the AppStore

I am just about to update one application from me. This app uses Core Data for saving the data, which the user puts in.
Now I want to fix some bugs, which aren't associated with Core Data at all.
What do I have to do that the User gets his data after downloading the Update?
I don't think about Lightweight Migration, because I haven't changed anything.
Do I have to add a new Model Versioning File? - I don't know.
You don't have to to anything. If the model and the data is not updated as part of the update, and you are storing the user's data in the documents directory, then a new version of your app will just carry on using the existing data.
If you haven't changed your Core Data schema at all, then you don't have to do anything. It'll still read the old data files with no problem.

Migration options for preloaded sqlite database in iphone app

My app uses a preloaded SQLLite database with coredata bindings. I create the preloaded database file with a secondary app that has the core data bindings/model etc. I put the preloaded db into my app's resources folder and copy that to the writable documents folder when the app is first run.
My question is about migration. Since my app released, my users have been creating data and in my next release I want to change the data model and migrate some of the data to the new model. I'm just not sure the best way to do this. I've read about core data migration methods but they seem to require my app to be a core data project, which it isn't (though my secondary database-creating app is). Will I have to do this migration manually by issuing direct SQL statements against the db? And what about the core data bindings, will I have to manually update them?
I'm really just looking for pointers in the right/best direction. Any suggestions? Thanks in advance!
SQLLite doesn't really have any data migration tools like Core Data. Unless you count "ALTER TABLE". If the migration is very complex, or you think you will have more complex migrations in the future you could make a Core Data model that more or less lines up with the old SQLite model and import to it, and then migrate to a newer Core Data model, and then stick with it.
This is likely slower then ALTER TABLE though, or at the very least "not faster".

Is there a a way to migrate data from Core Data to Online Database?

My app currently uses core data. I created a new version of the app that is all cloud based and the database is online. Therefore this requires user registration/accounts to access the data. The easiest thing is for me to make it a separate app, but then I lose the user base I already have.
Is there a way for me to transfer data from the iPhone's core data database to the online database? I am using https://www.parse.com/
Have a look into this github project,
https://github.com/itsniper/FTASync
Sure. To transfer data from CoreData to Parse, just create a PFObject for each row in your CoreData table, and save them to Parse. You can use saveAll to be faster. Then, you don't need the local copy in CoreData any more, so you can remove it.

Core Data Model change app update

I would like to update my app, but I have completely changed the data structure, so is the Core Data model entirely different. Now, the data in the app does not have to be preserved, but you can't just update the app with this new model as it will crash.
What is the best way to update my app?
You need to version the core data structure. Use this guide
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreDataVersioning/Articles/Introduction.html
If you have a completely new data model you might look into having a new database persistent-store/db file and run a merge function if the app can find an old database.

Preserving core data after app update

I am using core data to store favorites chosen by the user. I would like to know that if I send an app update, how can I keep the data of the favorites preserved after the app is updated by the user?
I have read that you could use versioning, but I'm not sure if this the correct method.
Any help will be appreciated! Thanks
If your app maintains the same bundle identifier and you don't copy over the core data store file, you keep it.
If you changed your Core Data model, then you do need to worry about versioning. Depending on changes you may need to write rules for migrating data in the old store to the new format. As you have probably experienced, if you change data structure and do not migrate (or wipe existing data), you crash.