mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 18:26:57 +00:00
Fix db inconsistency.
This commit is contained in:
committed by
Cody Henthorne
parent
7ed77a00df
commit
a0131bf39b
@@ -90,6 +90,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V229_MarkMissedCall
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V230_UnreadCountIndices
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V231_ArchiveThumbnailColumns
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V232_CreateInAppPaymentTable
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V233_FixInAppPaymentTableDefaultNotifiedValue
|
||||
|
||||
/**
|
||||
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
|
||||
@@ -182,10 +183,11 @@ object SignalDatabaseMigrations {
|
||||
229 to V229_MarkMissedCallEventsNotified,
|
||||
230 to V230_UnreadCountIndices,
|
||||
231 to V231_ArchiveThumbnailColumns,
|
||||
232 to V232_CreateInAppPaymentTable
|
||||
232 to V232_CreateInAppPaymentTable,
|
||||
233 to V233_FixInAppPaymentTableDefaultNotifiedValue
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 232
|
||||
const val DATABASE_VERSION = 233
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Updates notified default value from 0 to 1
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V233_FixInAppPaymentTableDefaultNotifiedValue : SignalDatabaseMigration {
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
db.execSQL(
|
||||
"""
|
||||
CREATE TABLE in_app_payment_tmp (
|
||||
_id INTEGER PRIMARY KEY,
|
||||
type INTEGER NOT NULL,
|
||||
state INTEGER NOT NULL,
|
||||
inserted_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
notified INTEGER DEFAULT 1,
|
||||
subscriber_id TEXT,
|
||||
end_of_period INTEGER DEFAULT 0,
|
||||
data BLOB NOT NULL
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
db.execSQL(
|
||||
"""
|
||||
INSERT INTO in_app_payment_tmp
|
||||
SELECT
|
||||
_id,
|
||||
type,
|
||||
state,
|
||||
inserted_at,
|
||||
updated_at,
|
||||
notified,
|
||||
subscriber_id,
|
||||
end_of_period,
|
||||
data
|
||||
FROM in_app_payment
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
db.execSQL("DROP TABLE in_app_payment")
|
||||
db.execSQL("ALTER TABLE in_app_payment_tmp RENAME TO in_app_payment")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user