Tassos Voulgaris
Tassos Voulgaris

Reputation: 888

SQLite database update when updating app via iTunes / AppStore

During an app update via the App Store I want to update the SQLite database file with more content. The old SQLite file is in the Documents folder of my app.

How do I handle this?

Upvotes: 0

Views: 271

Answers (2)

mprivat
mprivat

Reputation: 21902

I'm assuming you're not using Core Data or else you'd be using the auto-migration feature. For straight SQLLite you'll want to create a new database file. Then depending on the nature of your schema changes, you might be able to execute a query to copy the data over (using INSERT INTO destination SELECT * FROM source) . But if the changes are too much to handle with a simple set of queries, for example if it involves business logic, then you might need to write a script to convert the old data from one database to the new one.

Upvotes: 1

Sully
Sully

Reputation: 14943

sqlite> attach 'path_to_table.db3' as toMerge;           
sqlite> insert into MyTableToInsertTo select * from toMerge.MyTableToInsertFrom; 
sqlite> detach database toMerge; 

use BEGIN; COMMIT; for large data

link

Upvotes: 1

Related Questions