Fix incorrect data migration.

This commit is contained in:
Cody Henthorne 2023-09-30 09:15:37 -04:00
parent df7bb13752
commit d3e9303d6d
2 changed files with 10 additions and 6 deletions

View file

@ -63,7 +63,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V204_GroupForeignKe
import org.thoughtcrime.securesms.database.helpers.migration.V205_DropPushTable
import org.thoughtcrime.securesms.database.helpers.migration.V206_AddConversationCountIndex
import org.thoughtcrime.securesms.database.helpers.migration.V207_AddChunkSizeColumn
import org.thoughtcrime.securesms.database.helpers.migration.V208_ClearRecipientPniFromAciColumn
import org.thoughtcrime.securesms.database.helpers.migration.V209_ClearRecipientPniFromAciColumn
/**
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
@ -72,7 +72,7 @@ object SignalDatabaseMigrations {
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
const val DATABASE_VERSION = 208
const val DATABASE_VERSION = 209
@JvmStatic
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
@ -313,7 +313,11 @@ object SignalDatabaseMigrations {
}
if (oldVersion < 208) {
V208_ClearRecipientPniFromAciColumn.migrate(context, db, oldVersion, newVersion)
// Bad migration that only manipulated data and did not change schema, replaced by 209
}
if (oldVersion < 209) {
V209_ClearRecipientPniFromAciColumn.migrate(context, db, oldVersion, newVersion)
}
}

View file

@ -9,11 +9,11 @@ import android.app.Application
import net.zetetic.database.sqlcipher.SQLiteDatabase
/**
* PNIs were incorrectly being set to ACI column, remove them if present.
* PNIs were incorrectly being set to ACI column, clear them if present.
*/
@Suppress("ClassName")
object V208_ClearRecipientPniFromAciColumn : SignalDatabaseMigration {
object V209_ClearRecipientPniFromAciColumn : SignalDatabaseMigration {
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL("DELETE FROM recipient WHERE aci LIKE 'PNI:%'")
db.execSQL("UPDATE recipient SET aci = NULL WHERE aci LIKE 'PNI:%'")
}
}