From 0d715d2c1847affd4533db928306dc0829107943 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Tue, 18 Oct 2022 13:53:33 -0400 Subject: [PATCH] Cherry pick mentions badge database migration. --- .../database/helpers/SignalDatabaseMigrations.kt | 7 ++++++- .../migration/V159_ThreadUnreadSelfMentionCount.kt | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V159_ThreadUnreadSelfMentionCount.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt index 6f17717af0..284deaec8b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt @@ -13,13 +13,14 @@ import org.thoughtcrime.securesms.database.helpers.migration.V155_SmsExporterMig import org.thoughtcrime.securesms.database.helpers.migration.V156_RecipientUnregisteredTimestampMigration import org.thoughtcrime.securesms.database.helpers.migration.V157_RecipeintHiddenMigration import org.thoughtcrime.securesms.database.helpers.migration.V158_GroupsLastForceUpdateTimestampMigration +import org.thoughtcrime.securesms.database.helpers.migration.V159_ThreadUnreadSelfMentionCount /** * Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness. */ object SignalDatabaseMigrations { - const val DATABASE_VERSION = 158 + const val DATABASE_VERSION = 159 @JvmStatic fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { @@ -62,6 +63,10 @@ object SignalDatabaseMigrations { if (oldVersion < 158) { V158_GroupsLastForceUpdateTimestampMigration.migrate(context, db, oldVersion, newVersion) } + + if (oldVersion < 159) { + V159_ThreadUnreadSelfMentionCount.migrate(context, db, oldVersion, newVersion) + } } @JvmStatic diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V159_ThreadUnreadSelfMentionCount.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V159_ThreadUnreadSelfMentionCount.kt new file mode 100644 index 0000000000..4fe845544c --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V159_ThreadUnreadSelfMentionCount.kt @@ -0,0 +1,10 @@ +package org.thoughtcrime.securesms.database.helpers.migration + +import android.app.Application +import net.zetetic.database.sqlcipher.SQLiteDatabase + +object V159_ThreadUnreadSelfMentionCount : SignalDatabaseMigration { + override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + db.execSQL("ALTER TABLE thread ADD COLUMN unread_self_mention_count INTEGER DEFAULT 0") + } +}