Adding migration for event identifiers
This commit is contained in:
parent
d656cc1698
commit
710421d5bb
@ -133,6 +133,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if oldSchemaVersion <= 34 {
|
||||||
|
var ids: Set<String> = Set()
|
||||||
|
migration.enumerateObjects(ofType: "VehicleEvent") { old, new in
|
||||||
|
guard let oldId = old?["id"] as? String? else { return }
|
||||||
|
|
||||||
|
var newId = oldId ?? UUID().uuidString
|
||||||
|
if ids.contains(newId) {
|
||||||
|
newId = UUID().uuidString
|
||||||
|
}
|
||||||
|
ids.insert(newId)
|
||||||
|
|
||||||
|
new?["id"] = newId
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Realm.Configuration.defaultConfiguration = config
|
Realm.Configuration.defaultConfiguration = config
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user