From c446d4bb54b662970037d2e9bb3058d5c669743b Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Thu, 19 Oct 2023 10:39:08 -0400 Subject: [PATCH] Fix crash in pni typing migration. --- .../migration/V210_FixPniPossibleColumns.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V210_FixPniPossibleColumns.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V210_FixPniPossibleColumns.kt index fc58dbb6f8..2a67c8ea98 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V210_FixPniPossibleColumns.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V210_FixPniPossibleColumns.kt @@ -27,20 +27,20 @@ object V210_FixPniPossibleColumns : SignalDatabaseMigration { private val TAG = Log.tag(V210_FixPniPossibleColumns::class.java) override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - val pni = getLocalPni(context) + val pni = getLocalPni(context)?.toStringWithoutPrefix() if (pni == null) { Log.i(TAG, "No local PNI, nothing to migrate") return } - db.execSQL("UPDATE identities SET address = 'PNI:' || address WHERE address = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE one_time_prekeys SET account_id = 'PNI:' || account_id WHERE account_id = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE kyber_prekey SET account_id = 'PNI:' || account_id WHERE account_id = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE sender_key_shared SET address = 'PNI:' || address WHERE address = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE sender_keys SET address = 'PNI:' || address WHERE address = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE sessions SET address = 'PNI:' || address WHERE address = '${pni.toStringWithoutPrefix()}'") - db.execSQL("UPDATE signed_prekeys SET account_id = 'PNI:' || account_id WHERE account_id = '${pni.toStringWithoutPrefix()}'") + db.execSQL("UPDATE OR IGNORE identities SET address = 'PNI:' || address WHERE address = '$pni'") + db.execSQL("UPDATE OR IGNORE one_time_prekeys SET account_id = 'PNI:' || account_id WHERE account_id = '$pni'") + db.execSQL("UPDATE OR IGNORE kyber_prekey SET account_id = 'PNI:' || account_id WHERE account_id = '$pni'") + db.execSQL("UPDATE OR IGNORE sender_key_shared SET address = 'PNI:' || address WHERE address = '$pni'") + db.execSQL("UPDATE OR IGNORE sender_keys SET address = 'PNI:' || address WHERE address = '$pni'") + db.execSQL("UPDATE OR IGNORE sessions SET address = 'PNI:' || address WHERE address = '$pni'") + db.execSQL("UPDATE OR IGNORE signed_prekeys SET account_id = 'PNI:' || account_id WHERE account_id = '$pni'") } private fun getLocalPni(context: Application): ServiceId.PNI? {