Skip to content

Commit 2b46b6a

Browse files
committed
Fix upgrade failure
* Always commit even on SQL failure, this will Fix onUpgrade being call more that one time
1 parent 40f5042 commit 2b46b6a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalDbHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,10 @@ private static void upgradeOutcomeTableRevision1To2(SQLiteDatabase db) {
281281
// 3.12.1 quickly replaced 3.12.0 so converting cache isn't critical.
282282
db.execSQL("INSERT INTO outcome (" + commonColumns + ", weight) SELECT " + commonColumns + ", 0 FROM outcome_backup;");
283283
db.execSQL("DROP TABLE outcome_backup;");
284-
db.execSQL("COMMIT;");
285284
} catch (SQLiteException e) {
286285
e.printStackTrace();
286+
} finally {
287+
db.execSQL("COMMIT;");
287288
}
288289
}
289290

OneSignalSDK/onesignal/src/main/java/com/onesignal/outcomes/OSOutcomeTableProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ public void upgradeOutcomeTableRevision2To3(SQLiteDatabase db) {
7070
db.execSQL("INSERT INTO " + OutcomeEventsTable.TABLE_NAME + "(" + commonColumnsWithNewSessionColumn + ")" +
7171
" SELECT " + commonColumnsWithSessionColumn + " FROM " + auxOutcomeTableName + ";");
7272
db.execSQL("DROP TABLE " + auxOutcomeTableName + ";");
73-
db.execSQL("COMMIT;");
7473
} catch (SQLiteException e) {
7574
e.printStackTrace();
75+
} finally {
76+
db.execSQL("COMMIT;");
7677
}
7778
}
7879

@@ -103,9 +104,10 @@ public void upgradeCacheOutcomeTableRevision1To2(SQLiteDatabase db) {
103104
db.execSQL("UPDATE " + CachedUniqueOutcomeTable.TABLE_NAME +
104105
" SET " + CachedUniqueOutcomeTable.COLUMN_CHANNEL_TYPE + " = \'" + OSInfluenceChannel.NOTIFICATION.toString() + "\';");
105106
db.execSQL("DROP TABLE " + oldCacheUniqueOutcomeTable + ";");
106-
db.execSQL("COMMIT;");
107107
} catch (SQLiteException e) {
108108
e.printStackTrace();
109+
} finally {
110+
db.execSQL("COMMIT;");
109111
}
110112
}
111113

0 commit comments

Comments
 (0)