Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Keep the old sqlite database while updating to new version

I've found some other question but I didn't get any clear idea how to keep the data from old database while application update in ios.

Case 1: Can I keep the old database?

if Case 1 is YES: Can I insert new column or doing any changes in the old database and will it be safe?

if case 1 is NO: Can I get the old database data in new database? Will the old database will be removed?

Case 2: If I give a different name to new data base (it'll be included in bundle)? If giving a new name keeps the old database can I delete the old database programatically?

What will be the best practice? Give a new name to database file for keeping the old one and then copy the old to to new database and delete the old database file? Just start using the old one?

Looking for help.. :)

like image 237
Rashad Avatar asked Oct 20 '22 15:10

Rashad


1 Answers

Case 1: Can I keep the old database?

Yes, updating your application won't delete the database file stored in the documents directory. (But if it is in your bundle, it'll be removed)

if Case 1 is YES: Can I insert new column or doing any changes in the old database and will it be safe?

That'll depend on your implementation. You can use ALTER TABLE query for adding or removing column. You need to handle the new changes in your code, else it can cause problems. Adding a column won't cause any issues in normal scenarios (Depends on your insert query statements and new field constraints)

like image 151
Midhun MP Avatar answered Oct 27 '22 15:10

Midhun MP