Add extra guard during db migration.

Relates to #13183
This commit is contained in:
Greyson Parrelli 2024-01-02 10:29:03 -05:00 committed by Clark Chen
parent 1b9cf631be
commit 820a5bc363

View file

@ -66,10 +66,12 @@ object V166_ThreadAndMessageForeignKeys : SignalDatabaseMigration {
Log.w(TAG, "There were $count threads for RecipientId::$recipientId. Merging.", true)
val threads: List<ThreadInfo> = getThreadsByRecipientId(db, cursor.requireLong("thread_recipient_id"))
if (threads.size > 1) {
mergeThreads(db, threads)
}
}
}
}
private fun getThreadsByRecipientId(db: SQLiteDatabase, recipientId: Long): List<ThreadInfo> {
return db.rawQuery("SELECT _id, date FROM thread WHERE thread_recipient_id = ?".trimIndent(), recipientId).readToList { cursor ->