Cleanup dangling MSL rows.

This commit is contained in:
Greyson Parrelli
2023-02-09 13:41:32 -05:00
committed by GitHub
parent cf71e2cfa8
commit d8eac87219
3 changed files with 47 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V175_FixFullTextSea
import org.thoughtcrime.securesms.database.helpers.migration.V176_AddScheduledDateToQuoteIndex
import org.thoughtcrime.securesms.database.helpers.migration.V177_MessageSendLogTableCleanupMigration
import org.thoughtcrime.securesms.database.helpers.migration.V178_ReportingTokenColumnMigration
import org.thoughtcrime.securesms.database.helpers.migration.V179_CleanupDanglingMessageSendLogMigration
/**
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
@@ -42,7 +43,7 @@ object SignalDatabaseMigrations {
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
const val DATABASE_VERSION = 178
const val DATABASE_VERSION = 179
@JvmStatic
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
@@ -165,6 +166,10 @@ object SignalDatabaseMigrations {
if (oldVersion < 178) {
V178_ReportingTokenColumnMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 179) {
V179_CleanupDanglingMessageSendLogMigration.migrate(context, db, oldVersion, newVersion)
}
}
@JvmStatic

View File

@@ -0,0 +1,14 @@
package org.thoughtcrime.securesms.database.helpers.migration
import android.app.Application
import net.zetetic.database.sqlcipher.SQLiteDatabase
/**
* This cleans up some MSL entries that we left behind during a bad past migration.
*/
object V179_CleanupDanglingMessageSendLogMigration : SignalDatabaseMigration {
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL("DELETE FROM msl_message WHERE payload_id NOT IN (SELECT _id FROM msl_payload)")
db.execSQL("DELETE FROM msl_recipient WHERE payload_id NOT IN (SELECT _id FROM msl_payload)")
}
}