From 1411157bde215e8297aa988dcae2384907de3efc Mon Sep 17 00:00:00 2001 From: ronaldheft Date: Fri, 26 Aug 2022 20:20:46 -0400 Subject: [PATCH] Reindex server configs and fix bad data --- ios/App/App/AppDelegate.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift index 6e93aab0..b37c9931 100644 --- a/ios/App/App/AppDelegate.swift +++ b/ios/App/App/AppDelegate.swift @@ -11,7 +11,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Override point for customization after application launch. let configuration = Realm.Configuration( - schemaVersion: 3, + schemaVersion: 4, migrationBlock: { migration, oldSchemaVersion in if (oldSchemaVersion < 1) { NSLog("Realm schema version was \(oldSchemaVersion)") @@ -19,6 +19,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { newObject?["enableAltView"] = false } } + if (oldSchemaVersion < 4) { + NSLog("Realm schema version was \(oldSchemaVersion)... Reindexing server configs") + var indexCounter = 1 + migration.enumerateObjects(ofType: ServerConnectionConfig.className()) { oldObject, newObject in + newObject?["index"] = indexCounter + indexCounter += 1 + } + } } ) Realm.Configuration.defaultConfiguration = configuration