From ea6b756c0fb3c1337b615a9fb4c511a7b74cb90d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 13 Jul 2017 19:28:16 +0200 Subject: [PATCH] fixed bug in db migrations when going from <15 to something recent --- .../conversations/persistance/DatabaseBackend.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 589858b86..e9684a364 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -277,8 +277,6 @@ public class DatabaseBackend extends SQLiteOpenHelper { recreateAxolotlDb(db); db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " + Message.FINGERPRINT + " TEXT"); - } else if (oldVersion < 22 && newVersion >= 22) { - db.execSQL("ALTER TABLE " + SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN " + SQLiteAxolotlStore.CERTIFICATE); } if (oldVersion < 16 && newVersion >= 16) { db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " @@ -338,6 +336,10 @@ public class DatabaseBackend extends SQLiteOpenHelper { } } + if (oldVersion >= 15 && oldVersion < 22 && newVersion >= 22) { + db.execSQL("ALTER TABLE " + SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN " + SQLiteAxolotlStore.CERTIFICATE); + } + if (oldVersion < 23 && newVersion >= 23) { db.execSQL(CREATE_DISCOVERY_RESULTS_STATEMENT); } @@ -368,7 +370,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { if (oldVersion < 30 && newVersion >= 30) { db.execSQL(CREATE_START_TIMES_TABLE); } - if (oldVersion < 31 && newVersion >= 31) { + if (oldVersion >= 15 && oldVersion < 31 && newVersion >= 31) { db.execSQL("ALTER TABLE "+ SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN "+SQLiteAxolotlStore.TRUST + " TEXT"); db.execSQL("ALTER TABLE "+ SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN "+SQLiteAxolotlStore.ACTIVE + " NUMBER"); HashMap migration = new HashMap<>(); @@ -388,13 +390,13 @@ public class DatabaseBackend extends SQLiteOpenHelper { } } - if (oldVersion < 32 && newVersion >= 32) { + if (oldVersion >= 15 && oldVersion < 32 && newVersion >= 32) { db.execSQL("ALTER TABLE "+ SQLiteAxolotlStore.IDENTITIES_TABLENAME + " ADD COLUMN "+SQLiteAxolotlStore.LAST_ACTIVATION + " NUMBER"); ContentValues defaults = new ContentValues(); defaults.put(SQLiteAxolotlStore.LAST_ACTIVATION,System.currentTimeMillis()); db.update(SQLiteAxolotlStore.IDENTITIES_TABLENAME,defaults,null,null); } - if (oldVersion < 33 && newVersion >= 33) { + if (oldVersion >= 15 && oldVersion < 33 && newVersion >= 33) { String whereClause = SQLiteAxolotlStore.OWN+"=1"; db.update(SQLiteAxolotlStore.IDENTITIES_TABLENAME,createFingerprintStatusContentValues(FingerprintStatus.Trust.VERIFIED,true),whereClause,null); }