iOS SQLite.swift, regarding upgrade of app?

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.

  • Subtle cast warning when using SQLite.Swift … Binding? to Any
  • Adding an Xcode subproject: Shouldn't all the source files get copied?
  • sqlite.swift linked library or also embedded?
  • Using variables in Filters in SQLite.swift
  • Can I cast Int64 directly into Int?
  • How to get a list of column names with Sqlite.swift?
  • 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.)

    Solutions Collect From Internet About “iOS SQLite.swift, regarding upgrade of app?”

    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.