kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add back missing reaction triggers.
rodzic
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.V165_MmsMessageBoxPaymentTransactionIndexMigration
|
||||
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.
|
||||
|
@ -30,7 +31,7 @@ object SignalDatabaseMigrations {
|
|||
|
||||
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
|
||||
|
||||
const val DATABASE_VERSION = 166
|
||||
const val DATABASE_VERSION = 167
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
@ -105,6 +106,10 @@ object SignalDatabaseMigrations {
|
|||
if (oldVersion < 166) {
|
||||
V166_ThreadAndMessageForeignKeys.migrate(context, db, oldVersion, newVersion)
|
||||
}
|
||||
|
||||
if (oldVersion < 167) {
|
||||
V167_RecreateReactionTriggers.migrate(context, db, oldVersion, newVersion)
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue