|
|
|
|
@ -2,6 +2,7 @@ package net.pokeranalytics.android.model.migrations |
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import io.realm.kotlin.where |
|
|
|
|
import net.pokeranalytics.android.model.filter.Query |
|
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
|
@ -49,6 +50,22 @@ class Patcher { |
|
|
|
|
patchMissingTransactionTypes(context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Preferences.executeOnce(Preferences.Keys.PATCH_ZERO_TABLE, context) { |
|
|
|
|
patchZeroTable() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun patchZeroTable() { |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
val zero = 0 |
|
|
|
|
val sessions = realm.where<Session>().equalTo("numberOfTables", zero).findAll() |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
sessions.forEach { s -> |
|
|
|
|
s.numberOfTables = 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
realm.close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun patchMissingTransactionTypes(context: Context) { |
|
|
|
|
|