Add ScheduledMessage to realm schema

This commit is contained in:
Moez Bhatti
2018-06-26 15:28:01 -04:00
parent ad202a2f64
commit 431edfe2ee
5 changed files with 110 additions and 2 deletions
@@ -26,7 +26,7 @@ import io.realm.RealmMigration
class QkRealmMigration : RealmMigration {
companion object {
const val SCHEMA_VERSION: Long = 3
const val SCHEMA_VERSION: Long = 4
}
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
@@ -53,6 +53,18 @@ class QkRealmMigration : RealmMigration {
version++
}
if (version == 3L) {
realm.schema.create("ScheduledMessage")
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
.addField("date", Long::class.java, FieldAttribute.REQUIRED)
.addRealmListField("recipients", String::class.java)
.addField("sendAsGroup", Boolean::class.java, FieldAttribute.REQUIRED)
.addField("body", String::class.java, FieldAttribute.REQUIRED)
.addRealmListField("attachments", String::class.java)
version++
}
if (version < newVersion) {
throw IllegalStateException("Migration missing from v$oldVersion to v$newVersion")
}