mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Add back missing reaction triggers.
This commit is contained in:
committed by
Cody Henthorne
parent
21a8434e4d
commit
ebe82cf3e6
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V163_RemoteMegaphon
|
|||||||
import org.thoughtcrime.securesms.database.helpers.migration.V164_ThreadDatabaseReadIndexMigration
|
import org.thoughtcrime.securesms.database.helpers.migration.V164_ThreadDatabaseReadIndexMigration
|
||||||
import org.thoughtcrime.securesms.database.helpers.migration.V165_MmsMessageBoxPaymentTransactionIndexMigration
|
import org.thoughtcrime.securesms.database.helpers.migration.V165_MmsMessageBoxPaymentTransactionIndexMigration
|
||||||
import org.thoughtcrime.securesms.database.helpers.migration.V166_ThreadAndMessageForeignKeys
|
import org.thoughtcrime.securesms.database.helpers.migration.V166_ThreadAndMessageForeignKeys
|
||||||
|
import org.thoughtcrime.securesms.database.helpers.migration.V167_RecreateReactionTriggers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
|
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
|
||||||
@@ -30,7 +31,7 @@ object SignalDatabaseMigrations {
|
|||||||
|
|
||||||
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
|
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
|
||||||
|
|
||||||
const val DATABASE_VERSION = 166
|
const val DATABASE_VERSION = 167
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
@@ -105,6 +106,10 @@ object SignalDatabaseMigrations {
|
|||||||
if (oldVersion < 166) {
|
if (oldVersion < 166) {
|
||||||
V166_ThreadAndMessageForeignKeys.migrate(context, db, oldVersion, newVersion)
|
V166_ThreadAndMessageForeignKeys.migrate(context, db, oldVersion, newVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < 167) {
|
||||||
|
V167_RecreateReactionTriggers.migrate(context, db, oldVersion, newVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.thoughtcrime.securesms.database.helpers.migration
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forgot to recreate the triggers for the reactions table in [V166_ThreadAndMessageForeignKeys]. So we gotta fix stuff up and do it here.
|
||||||
|
*/
|
||||||
|
object V167_RecreateReactionTriggers : SignalDatabaseMigration {
|
||||||
|
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
|
DELETE FROM reaction
|
||||||
|
WHERE
|
||||||
|
(is_mms = 0 AND message_id NOT IN (SELECT _id FROM sms))
|
||||||
|
OR
|
||||||
|
(is_mms = 1 AND message_id NOT IN (SELECT _id FROM mms))
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
|
CREATE TRIGGER IF NOT EXISTS reactions_sms_delete AFTER DELETE ON sms
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM reaction WHERE message_id = old._id AND is_mms = 0;
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
db.execSQL(
|
||||||
|
"""
|
||||||
|
CREATE TRIGGER IF NOT EXISTS reactions_mms_delete AFTER DELETE ON mms
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM reaction WHERE message_id = old._id AND is_mms = 1;
|
||||||
|
END
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user