The problem we face is we cannot migrate with the new schema version so we want to wipe out all the realm data clean and create a new one instead (for all the user who have schema version less than this new number).
But I cannot find a way for me to know this number except only during in the migration block.
Is there a way to know this schema version else where?
I found this answer here
let configCheck = Realm.Configuration();
do {
let fileUrlIs = try schemaVersionAtURL(configCheck.fileURL!)
print("schema version \(fileUrlIs)")
} catch {
print(error)
}
Technically you can't check the schema version without accessing the Realm file at all, but you don't need full access and specify a matching schema to read just the schema version. We have functions to allow exactly that.
From Objective-C, you can use the class method:+[RLMRealm schemaVersionAtPath:error:]
From Realm Swift, you can use the free function:
schemaVersionAtPath(_:encryptionKey:error:)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With