Sync starred contacts and groups

This commit is contained in:
moezbhatti
2019-10-27 17:50:27 -04:00
committed by Moez Bhatti
parent 28cad9bbc9
commit 8f67de736a
11 changed files with 267 additions and 50 deletions
@@ -26,7 +26,7 @@ import io.realm.Sort
class QkRealmMigration : RealmMigration {
companion object {
const val SCHEMA_VERSION: Long = 8
const val SCHEMA_VERSION: Long = 9
}
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
@@ -118,6 +118,18 @@ class QkRealmMigration : RealmMigration {
version++
}
if (version == 8L) {
realm.schema.create("ContactGroup")
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
.addField("title", String::class.java, FieldAttribute.REQUIRED)
.addRealmListField("contacts", realm.schema.get("Contact"))
realm.schema.get("Contact")
?.addField("starred", Boolean::class.java, FieldAttribute.REQUIRED)
version++
}
check(version >= newVersion) { "Migration missing from v$oldVersion to v$newVersion" }
}