From 7f4603a1baa960778ade47a826653b31076694d0 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 17 Feb 2021 11:30:37 +1100 Subject: [PATCH] Fix DB migration --- .../database/helpers/SQLCipherOpenHelper.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 3174665403..ecb17b8c10 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -56,12 +56,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV18_CLEAR_BG_POLL_JOBS = 39; //TODO Merge all "refactor" migrations to one before pushing to the main repo. private static final int lokiV19 = 40; - private static final int lokiV19_REFACTOR1 = 41; - private static final int lokiV19_REFACTOR2 = 42; - + private static final int lokiV20 = 41; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes - private static final int DATABASE_VERSION = lokiV19_REFACTOR2; + private static final int DATABASE_VERSION = lokiV20; private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -220,17 +218,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { } // Many classes were removed. We need to update DB structure and data to match the code changes. - //TODO Merge "refactor" changes in one migration. if (oldVersion < lokiV19) { db.execSQL(LokiAPIDatabase.getCreateClosedGroupEncryptionKeyPairsTable()); db.execSQL(LokiAPIDatabase.getCreateClosedGroupPublicKeysTable()); ClosedGroupsMigration.INSTANCE.perform(db); - } - if (oldVersion < lokiV19_REFACTOR1) { db.execSQL("DROP TABLE identities"); deleteJobRecords(db, "RetrieveProfileJob"); - } - if (oldVersion < lokiV19_REFACTOR2) { deleteJobRecords(db, "RefreshAttributesJob", "RotateProfileKeyJob", @@ -239,6 +232,15 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { ); } + if (oldVersion < lokiV20) { + deleteJobRecords(db, + "CleanPreKeysJob", + "RefreshPreKeysJob", + "CreateSignedPreKeysJob", + "RotateSignedPreKeyJob" + ); + } + db.setTransactionSuccessful(); } finally { db.endTransaction();