From 120659120c5ff5c6bb3ceeab3fc69182e501d2d4 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:43:45 +1100 Subject: [PATCH] Check if columns exist before migration --- .../database/helpers/SQLCipherOpenHelper.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 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 5bc8c58ba4..1eae623dad 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 @@ -630,8 +630,17 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { } if (oldVersion < lokiV47) { - db.execSQL(SmsDatabase.ADD_IS_DELETED_COLUMN); - db.execSQL(MmsDatabase.ADD_IS_DELETED_COLUMN); + // Ideally we shouldn't need to check if the column exists, but somehow we get + // "duplicated column" from play store crashes. + // If you are keen you can investigate + // deep into this but for now, we will just check if the column exists before adding it. + if (!columnExists(db, SmsDatabase.TABLE_NAME, SmsDatabase.IS_DELETED)) { + db.execSQL(SmsDatabase.ADD_IS_DELETED_COLUMN); + } + + if (!columnExists(db, MmsDatabase.TABLE_NAME, MmsDatabase.IS_DELETED)) { + db.execSQL(MmsDatabase.ADD_IS_DELETED_COLUMN); + } } db.setTransactionSuccessful();