From 88f955602aaee47840ef0badd92cb2e2c623b13d Mon Sep 17 00:00:00 2001 From: bepaald <38437099+bepaald@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:35:22 +0000 Subject: [PATCH] Fix creating message_fts table during database migration. Fixes #13034, fixes #13506 --- .../database/helpers/migration/V175_FixFullTextSearchLink.kt | 4 ++++ 1 file changed, 4 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 c1ab575ebe0..a62b99611d7 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 @@ -23,6 +23,10 @@ object V175_FixFullTextSearchLink : SignalDatabaseMigration { db.execSQL("CREATE VIRTUAL TABLE message_fts USING fts5(body, thread_id UNINDEXED, content=message, content_rowid=_id)") + // The newly created search table is empty, while its content-table (message) is not. To get the search + // table in a consistent state, it needs to be rebuilt. + db.execSQL("INSERT INTO message_fts(message_fts) VALUES ('rebuild')") + db.execSQL( """ CREATE TRIGGER message_ai AFTER INSERT ON message BEGIN