Sync subId when syncing message

This commit is contained in:
Moez Bhatti
2018-05-30 12:17:16 -04:00
parent c0968e4b42
commit f71d2564b2
9 changed files with 21 additions and 6 deletions
@@ -46,6 +46,7 @@ class CursorToMessageImpl @Inject constructor(
Mms.READ,
Mms.THREAD_ID,
Mms.LOCKED,
Mms.SUBSCRIPTION_ID,
Sms.ADDRESS,
Sms.BODY,
@@ -84,6 +85,7 @@ class CursorToMessageImpl @Inject constructor(
dateSent = cursor.getLong(columnsMap.dateSent)
read = cursor.getInt(columnsMap.read) != 0
locked = cursor.getInt(columnsMap.locked) != 0
subId = cursor.getInt(columnsMap.subId)
when (type) {
"sms" -> {
@@ -24,6 +24,10 @@ import io.realm.RealmMigration
class QkRealmMigration : RealmMigration {
companion object {
const val SCHEMA_VERSION: Long = 2
}
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
var version = oldVersion
@@ -34,6 +38,13 @@ class QkRealmMigration : RealmMigration {
version++
}
if (version == 1L) {
realm.schema.get("Message")
?.addField("subId", Int::class.java)
version++
}
if (version < newVersion) {
throw IllegalStateException("Migration missing from v$oldVersion to v$newVersion")
}