Deduplicate in migration to prevent constraint breakage.

This commit is contained in:
Alex Hart
2023-05-19 14:24:22 -03:00
committed by Greyson Parrelli
parent f2846efd2c
commit 77ccbdd322

View File

@@ -45,6 +45,17 @@ object V196_BackCallLinksWithRecipientV2 : SignalDatabaseMigration {
// drop all call events with a null peer. // drop all call events with a null peer.
db.execSQL("DELETE FROM call WHERE peer IS NULL") db.execSQL("DELETE FROM call WHERE peer IS NULL")
// drop all call events that have a later (by insertion) duplicate (by peer and call_id)
db.execSQL(
"""
DELETE FROM call
WHERE _id < (
SELECT MAX(_id) FROM call c2
WHERE c2.peer = call.peer AND c2.call_id = call.call_id
)
""".trimIndent()
)
// recreate the call table dropping the call_link column // recreate the call table dropping the call_link column
db.execSQL( db.execSQL(
""" """