From 0ef9af997c98d0252512cc53f436709e88a1e025 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Tue, 23 Aug 2016 12:17:58 +0200 Subject: Fixes conditions for cplus db upgrades --- .../de/thedevstack/conversationsplus/persistance/DatabaseBackend.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java index 6442e909..7c2583ae 100644 --- a/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java +++ b/src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java @@ -198,13 +198,13 @@ public class DatabaseBackend extends SQLiteOpenHelper { protected void onUpgradeCPlusDatabase(SQLiteDatabase db, int oldVersion, int newVersion) { Logging.d("db.upgrade.cplus", "Updating Conversations+ database from version '" + oldVersion + "' to '" + newVersion + "'"); if (oldVersion < newVersion) { - if (oldVersion == 0 && newVersion == 1) { + if (oldVersion < 1 && newVersion >= 1) { Logging.d("db.upgrade.cplus", "Creating additional parameters table for messages."); db.execSQL(MessageDatabaseAccess.TABLE_ADDITIONAL_PARAMETERS_CREATE_V0); db.execSQL("INSERT INTO " + MessageDatabaseAccess.TABLE_NAME_ADDITIONAL_PARAMETERS + "(" + MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_MSGUUID + ") " + " SELECT " + Message.UUID + " FROM " + Message.TABLENAME); } - if (newVersion == 2) { + if (oldVersion < 2 && newVersion >= 2) { Logging.d("db.upgrade.cplus", "Encrypt all passwords for the first time"); Cursor cursor = db.rawQuery("SELECT " + Account.UUID + ", " + Account.PASSWORD + " FROM " + Account.TABLENAME, new String[0]); while (cursor.moveToNext()) { -- cgit v1.2.3