I am using GreenDao in my Android app, and have a subclass of SQLiteOpenHelper which I call DBHelper:
public class DBHelper extends DaoMaster.OpenHelper {
// DaoMaster.OpenHelper extends SQLiteOpenHelper and passes in `SCHEMA_VERSION` which for me is 32
public static final String DATABASE_NAME = "my_app.db";
public DBHelper(Context context) {
super(context, DATABASE_NAME, null);
}
@Override
public void onCreate(SQLiteDatabase arg0) {
...
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
...
}
}
I have occasionally been seeing exceptions coming from within that onUpgrade method on code paths that only happen if oldVersion is less than 11 - my current schema version is 32, and version 11 is now well over six years old.
This is causing some very serious problems, because as part of the migration path from versions less than 11 I migrated to some new database tables, meaning the rollback involves dropping database tables, and as a result I've had some reports of data loss.
I don't really believe that oldVersion is correct - the bug reports I've had from users all say they installed the app for the first time quite recently. Does anybody have any ideas why this might happen?
Since anybody who has used the app in the last six years ought to have done the migration by now, I'm thinking I should just remove any code related to migrations from oldVersions less than 11 - am I likely to regret that, will that introduce any new problems?