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,11 +423,16 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
private void addCredentialsToRepo(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion < 52 && !columnExists(db, TABLE_REPO, "username") && !columnExists(db, TABLE_REPO, "password")) {
|
||||
Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db.");
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column username string;");
|
||||
Utils.debugLog(TAG, "Adding password field to " + TABLE_REPO + " table in db.");
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column password string;");
|
||||
if (oldVersion < 52) {
|
||||
if (!columnExists(db, TABLE_REPO, "username")) {
|
||||
Utils.debugLog(TAG, "Adding username field to " + TABLE_REPO + " table in db.");
|
||||
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.");
|
||||
db.execSQL("alter table " + TABLE_REPO + " add column password string;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user