From 7d4bcd7f15a1b9659bd15a8db91b30973a405e45 Mon Sep 17 00:00:00 2001 From: Clark Date: Mon, 14 Aug 2023 15:43:42 -0400 Subject: [PATCH] Ignore message_fts table if needed in v175 migration. --- .../helpers/migration/V175_FixFullTextSearchLink.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V175_FixFullTextSearchLink.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V175_FixFullTextSearchLink.kt index 1bc607f1fa..c1ab575ebe 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V175_FixFullTextSearchLink.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V175_FixFullTextSearchLink.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database.helpers.migration import android.app.Application import net.zetetic.database.sqlcipher.SQLiteDatabase +import org.signal.core.util.SqlUtil /** * Turns out renaming a table will automatically update all of your indexes, foreign keys, triggers, basically everything... except full-text search tables. @@ -15,6 +16,11 @@ object V175_FixFullTextSearchLink : SignalDatabaseMigration { db.execSQL("DROP TRIGGER IF EXISTS mms_ad") db.execSQL("DROP TRIGGER IF EXISTS mms_au") + // We need to check because it's possible this table got created due to us hitting corruption first + if (SqlUtil.tableExists(db, "message_fts")) { + return + } + db.execSQL("CREATE VIRTUAL TABLE message_fts USING fts5(body, thread_id UNINDEXED, content=message, content_rowid=_id)") db.execSQL(