Regarding the magnificent and amazing SQLite.swift, I'm wondering
You have an app in the app store, v7. There's an upgrade to v8. User X does upgrade v7 to v8 using the app store.
Say in v8, we have slightly changed one of the sql tables, perhaps add a column or rename a column.
Should anything or must anything special be done in SQLite.swift in this case?
What's the SQLite.swift way to handle that?
(In for example, Android there's a handy onUpgrade concept in their helper class ... which comes with it's own set of complex issues.)
The implementation of SQLiteOpenHelper is quite simple:
db = SQLiteDatabase.openDatabase(...);
onConfigure(db);
int version = db.getVersion();
if (version != mNewVersion) {
db.beginTransaction();
try {
if (version == 0) {
onCreate(db);
} else {
if (version > mNewVersion) {
onDowngrade(db, version, mNewVersion);
} else {
onUpgrade(db, version, mNewVersion);
}
}
db.setVersion(mNewVersion);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
Just do the same in Swift.
For how to implement onUpgrade()
, see SQLiteOpenHelper onUpgrade() Confusion Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With