mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Fix database migration from 4.3.1
This commit is contained in:
@@ -37,7 +37,7 @@ class QkRealmMigration @Inject constructor(
|
||||
) : RealmMigration {
|
||||
|
||||
companion object {
|
||||
const val SCHEMA_VERSION: Long = 14
|
||||
const val SCHEMA_VERSION: Long = 15
|
||||
}
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
@@ -247,19 +247,6 @@ class QkRealmMigration @Inject constructor(
|
||||
.addField("isRegex", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
.addField("includeContacts", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
realm.schema.get("Conversation")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
?.transform { conversation ->
|
||||
conversation.setBoolean(
|
||||
"sendAsGroup",
|
||||
(conversation.getList("recipients").size > 1)
|
||||
)
|
||||
}
|
||||
|
||||
realm.schema.get("Message")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
|
||||
|
||||
version++
|
||||
}
|
||||
|
||||
@@ -294,6 +281,23 @@ class QkRealmMigration @Inject constructor(
|
||||
version++
|
||||
}
|
||||
|
||||
if (version == 14L) {
|
||||
if (realm.schema.get("Conversation")?.hasField("sendAsGroup") == false) {
|
||||
realm.schema.get("Conversation")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
?.transform { conversation ->
|
||||
conversation.setBoolean(
|
||||
"sendAsGroup",
|
||||
(conversation.getList("recipients").size > 1)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (realm.schema.get("Message")?.hasField("sendAsGroup") == false) {
|
||||
realm.schema.get("Message")
|
||||
?.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
|
||||
}
|
||||
}
|
||||
|
||||
check(version >= SCHEMA_VERSION) {
|
||||
"Migration from v$oldVersion to v$newVersion failed at v$version"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user