|
|
|
@ -2,6 +2,7 @@ package net.pokeranalytics.android.model.migrations |
|
|
|
|
|
|
|
|
|
|
|
import io.realm.DynamicRealm |
|
|
|
import io.realm.DynamicRealm |
|
|
|
import io.realm.RealmMigration |
|
|
|
import io.realm.RealmMigration |
|
|
|
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import timber.log.Timber |
|
|
|
import timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +172,50 @@ class PokerAnalyticsMigration : RealmMigration { |
|
|
|
|
|
|
|
|
|
|
|
currentVersion++ |
|
|
|
currentVersion++ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Migrate to version 9 |
|
|
|
|
|
|
|
if (currentVersion == 8) { |
|
|
|
|
|
|
|
schema.get("HandHistory")?.let { hhSchema -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema.get("Session")?.let { |
|
|
|
|
|
|
|
hhSchema.addRealmObjectField("session", it) |
|
|
|
|
|
|
|
} ?: throw PAIllegalStateException("Session schema not found") |
|
|
|
|
|
|
|
hhSchema.addField("smallBlind", Double::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("bigBlind", Double::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("ante", Double::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("bigBlindAnte", Boolean::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("numberOfPlayers", Int::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("comment", String::class.java) |
|
|
|
|
|
|
|
hhSchema.addField("heroIndex", Int::class.java).setRequired("heroIndex", false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val cardSchema = schema.create("Card") |
|
|
|
|
|
|
|
cardSchema.addField("value", Int::class.java) |
|
|
|
|
|
|
|
cardSchema.addField("suit", Int::class.java) |
|
|
|
|
|
|
|
hhSchema.addRealmListField("board", cardSchema) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val actionSchema = schema.create("Action") |
|
|
|
|
|
|
|
actionSchema.addField("street", Int::class.java) |
|
|
|
|
|
|
|
actionSchema.addField("index", Int::class.java) |
|
|
|
|
|
|
|
actionSchema.addField("position", Int::class.java) |
|
|
|
|
|
|
|
actionSchema.addField("typeIdentifier", Int::class.java).setRequired("typeIdentifier", false) |
|
|
|
|
|
|
|
actionSchema.addField("amount", Double::class.java).setRequired("amount", false) |
|
|
|
|
|
|
|
actionSchema.addField("effectiveAmount", Double::class.java) |
|
|
|
|
|
|
|
actionSchema.addField("positionRemainingStack", Double::class.java).setRequired("positionRemainingStack", false) |
|
|
|
|
|
|
|
hhSchema.addRealmListField("actions", actionSchema) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val playerSetupSchema = schema.create("PlayerSetup") |
|
|
|
|
|
|
|
schema.get("Player")?.let { |
|
|
|
|
|
|
|
playerSetupSchema.addRealmObjectField("player", it) |
|
|
|
|
|
|
|
} ?: throw PAIllegalStateException("Session schema not found") |
|
|
|
|
|
|
|
playerSetupSchema.addField("position", Int::class.java) |
|
|
|
|
|
|
|
playerSetupSchema.addField("stack", Double::class.java).setRequired("stack", false) |
|
|
|
|
|
|
|
playerSetupSchema.addRealmListField("cards", cardSchema) |
|
|
|
|
|
|
|
hhSchema.addRealmListField("playerSetups", playerSetupSchema) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentVersion++ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun equals(other: Any?): Boolean { |
|
|
|
override fun equals(other: Any?): Boolean { |
|
|
|
|