Be a little more concise about what to do when running migration for v64.
Before it is not apparant that the migration introduced for v64 is associated with that particular version. This is because the guard condition used to bail out from the upgrade is more closely related to a previous migration. This is due to a flaw with the desigh of `resetTransient()`, whereby it always resets the database to the schema _of the current F-Droid version being run_, not of the tables as they stood at the time of the particular migration being introduced. This clarifies the guard condition for v64 by instead explicitly asking if the columns of interest exist yet in this particular invocation of `onUpgrade()`.
This commit is contained in:
parent
5d2c2bc6e6
commit
a317877120
@ -360,28 +360,34 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
addObbFiles(db, oldVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* For upgrades from earlier than 63, this is created in
|
||||
* {@link #resetTransient(SQLiteDatabase)} in
|
||||
* {@link #migrateToPackageTable(SQLiteDatabase, int)}, so it only needs
|
||||
* to run when the database is at version 63.
|
||||
*/
|
||||
private void addObbFiles(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion != 63) {
|
||||
if (oldVersion >= 64) {
|
||||
return;
|
||||
}
|
||||
Utils.debugLog(TAG, "Adding " + ApkTable.Cols.OBB_MAIN_FILE
|
||||
+ ", " + ApkTable.Cols.OBB_PATCH_FILE
|
||||
+ ", and hash columns to " + ApkTable.NAME);
|
||||
|
||||
Utils.debugLog(TAG, "Ensuring " + ApkTable.Cols.OBB_MAIN_FILE + ", " +
|
||||
ApkTable.Cols.OBB_PATCH_FILE + ", and hash columns exist on " + ApkTable.NAME);
|
||||
|
||||
if (!columnExists(db, ApkTable.NAME, ApkTable.Cols.OBB_MAIN_FILE)) {
|
||||
db.execSQL("alter table " + ApkTable.NAME + " add column "
|
||||
+ ApkTable.Cols.OBB_MAIN_FILE + " string");
|
||||
}
|
||||
|
||||
if (!columnExists(db, ApkTable.NAME, ApkTable.Cols.OBB_MAIN_FILE_SHA256)) {
|
||||
db.execSQL("alter table " + ApkTable.NAME + " add column "
|
||||
+ ApkTable.Cols.OBB_MAIN_FILE_SHA256 + " string");
|
||||
}
|
||||
|
||||
if (!columnExists(db, ApkTable.NAME, ApkTable.Cols.OBB_PATCH_FILE)) {
|
||||
db.execSQL("alter table " + ApkTable.NAME + " add column "
|
||||
+ ApkTable.Cols.OBB_PATCH_FILE + " string");
|
||||
}
|
||||
|
||||
if (!columnExists(db, ApkTable.NAME, ApkTable.Cols.OBB_PATCH_FILE_SHA256)) {
|
||||
db.execSQL("alter table " + ApkTable.NAME + " add column "
|
||||
+ ApkTable.Cols.OBB_PATCH_FILE_SHA256 + " string");
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateToPackageTable(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion >= 63) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user