Made db migration more robust by wrapping in transaction.
This commit is contained in:
parent
b4e0bde57f
commit
94c9114862
@ -320,7 +320,9 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
private void migrateAppPrimaryKeyToRowId(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion < 58) {
|
||||
if (oldVersion < 58 && !columnExists(db, ApkTable.NAME, ApkTable.Cols.APP_ID)) {
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS name ON " + AppTable.NAME + " (" + AppTable.Cols.NAME + ")");
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS added ON " + AppTable.NAME + " (" + AppTable.Cols.ADDED + ")");
|
||||
|
||||
@ -336,6 +338,10 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
Log.i(TAG, "Updating foreign key from " + ApkTable.NAME + " to " + AppTable.NAME + " to use numeric foreign key.");
|
||||
Utils.debugLog(TAG, update);
|
||||
db.execSQL(update);
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user