mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Cleanup dangling MSL rows.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user