CR: Better deal with the possibility of crashes during database update.
This is for an abundance of caution. If the guard condition checks for the presence of both username _and_ password fields, then a crash or some sort of force close during the update (after adding username but before password) will mean that next time the app runs, this condition will evaluate to false and the password field will never get added.
This commit is contained in:
parent
97b60d937d
commit
3426b3bb2d
@ -423,13 +423,18 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addCredentialsToRepo(SQLiteDatabase db, int oldVersion) {
|
private void addCredentialsToRepo(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion < 52 && !columnExists(db, TABLE_REPO, "username") && !columnExists(db, TABLE_REPO, "password")) {
|
if (oldVersion < 52) {
|
||||||
|
if (!columnExists(db, TABLE_REPO, "username")) {
|
||||||
Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db.");
|
Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db.");
|
||||||
db.execSQL("alter table " + TABLE_REPO + " add column username string;");
|
db.execSQL("alter table " + TABLE_REPO + " add column username string;");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!columnExists(db, TABLE_REPO, "password")) {
|
||||||
Utils.debugLog(TAG, "Adding password field to " + TABLE_REPO + " table in db.");
|
Utils.debugLog(TAG, "Adding password field to " + TABLE_REPO + " table in db.");
|
||||||
db.execSQL("alter table " + TABLE_REPO + " add column password string;");
|
db.execSQL("alter table " + TABLE_REPO + " add column password string;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addChangelogToApp(SQLiteDatabase db, int oldVersion) {
|
private void addChangelogToApp(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion < 48 && !columnExists(db, TABLE_APP, "changelogURL")) {
|
if (oldVersion < 48 && !columnExists(db, TABLE_APP, "changelogURL")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user