-
-
Notifications
You must be signed in to change notification settings - Fork 6k
/
SignalDatabaseMigrations.kt
96 lines (77 loc) · 3.62 KB
/
SignalDatabaseMigrations.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package org.thoughtcrime.securesms.database.helpers
import android.app.Application
import android.content.Context
import net.zetetic.database.sqlcipher.SQLiteDatabase
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.database.helpers.migration.V149_LegacyMigrations
import org.thoughtcrime.securesms.database.helpers.migration.V150_UrgentMslFlagMigration
import org.thoughtcrime.securesms.database.helpers.migration.V151_MyStoryMigration
import org.thoughtcrime.securesms.database.helpers.migration.V152_StoryGroupTypesMigration
import org.thoughtcrime.securesms.database.helpers.migration.V153_MyStoryMigration
import org.thoughtcrime.securesms.database.helpers.migration.V154_PniSignaturesMigration
import org.thoughtcrime.securesms.database.helpers.migration.V155_SmsExporterMigration
import org.thoughtcrime.securesms.database.helpers.migration.V156_RecipientUnregisteredTimestampMigration
import org.thoughtcrime.securesms.database.helpers.migration.V157_RecipeintHiddenMigration
import org.thoughtcrime.securesms.database.helpers.migration.V158_GroupsLastForceUpdateTimestampMigration
import org.thoughtcrime.securesms.database.helpers.migration.V159_ThreadUnreadSelfMentionCount
import org.thoughtcrime.securesms.database.helpers.migration.V160_SmsMmsExportedIndexMigration
import org.thoughtcrime.securesms.database.helpers.migration.V161_StorySendMessageIdIndex
import org.thoughtcrime.securesms.database.helpers.migration.V162_ThreadUnreadSelfMentionCountFixup
/**
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
*/
object SignalDatabaseMigrations {
val TAG: String = Log.tag(SignalDatabaseMigrations.javaClass)
const val DATABASE_VERSION = 162
@JvmStatic
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
if (oldVersion < 149) {
V149_LegacyMigrations.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 150) {
V150_UrgentMslFlagMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 151) {
V151_MyStoryMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 152) {
V152_StoryGroupTypesMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 153) {
V153_MyStoryMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 154) {
V154_PniSignaturesMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 155) {
V155_SmsExporterMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 156) {
V156_RecipientUnregisteredTimestampMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 157) {
V157_RecipeintHiddenMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 158) {
V158_GroupsLastForceUpdateTimestampMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 159) {
V159_ThreadUnreadSelfMentionCount.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 160) {
V160_SmsMmsExportedIndexMigration.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 161) {
V161_StorySendMessageIdIndex.migrate(context, db, oldVersion, newVersion)
}
if (oldVersion < 162) {
V162_ThreadUnreadSelfMentionCountFixup.migrate(context, db, oldVersion, newVersion)
}
}
@JvmStatic
fun migratePostTransaction(context: Context, oldVersion: Int) {
if (oldVersion < V149_LegacyMigrations.MIGRATE_PREKEYS_VERSION) {
PreKeyMigrationHelper.cleanUpPreKeys(context)
}
}
}