Fix bugs with notification schedules caused by 24xx end times.

This commit is contained in:
Cody Henthorne
2024-12-05 10:49:24 -05:00
committed by Greyson Parrelli
parent 5cd0062688
commit 30ad854381
5 changed files with 41 additions and 23 deletions

View File

@@ -115,6 +115,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V255_AddCallTableLo
import org.thoughtcrime.securesms.database.helpers.migration.V256_FixIncrementalDigestColumns
import org.thoughtcrime.securesms.database.helpers.migration.V257_CreateBackupMediaSyncTable
import org.thoughtcrime.securesms.database.helpers.migration.V258_FixGroupRevokedInviteeUpdate
import org.thoughtcrime.securesms.database.helpers.migration.V259_AdjustNotificationProfileMidnightEndTimes
/**
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
@@ -232,10 +233,11 @@ object SignalDatabaseMigrations {
255 to V255_AddCallTableLogIndex,
256 to V256_FixIncrementalDigestColumns,
257 to V257_CreateBackupMediaSyncTable,
258 to V258_FixGroupRevokedInviteeUpdate
258 to V258_FixGroupRevokedInviteeUpdate,
259 to V259_AdjustNotificationProfileMidnightEndTimes
)
const val DATABASE_VERSION = 258
const val DATABASE_VERSION = 259
@JvmStatic
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {

View File

@@ -0,0 +1,23 @@
package org.thoughtcrime.securesms.database.helpers.migration
import android.app.Application
import net.zetetic.database.sqlcipher.SQLiteDatabase
/**
* Adjust notification profile schedules with end times between midnight at 1am. These were originally
* stored as 24xx and will now use the same as start with 00xx.
*/
@Suppress("ClassName")
object V259_AdjustNotificationProfileMidnightEndTimes : SignalDatabaseMigration {
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL(
"""
UPDATE
notification_profile_schedule
SET 'end' = end - 2400
WHERE
end >= 2400
"""
)
}
}