You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does it happen in production or during dev/test? Dev
Can the crash be reproduced by you? Yes
Can you provide instructions for how we can reproduce it? Change my primary key type from String to UUID. The migrationBlock is never called and the SDK crashes.
I changed my primary key type from String to UUID
OLD:
public class MyClass: Object {
@Persisted(primaryKey: true) public var id: String?
NEW:
public class MyClass: Object {
@Persisted(primaryKey: true) public var id: UUID?
configuration:
schemaVersion: 3,
migrationBlock: { migration, oldSchemaVersion in
/// THIS IS NEVER CALLED
if oldSchemaVersion == 1 {
} else if oldSchemaVersion == 2 {
migration.enumerateObjects(ofType: MyClass.className()) { oldObject, newObject in
newObject!["id"] = UUID(uuidString: oldObject!["id"]! as! String)
}
}
}
The text was updated successfully, but these errors were encountered:
Note that if I change some other non-primary-key field in that class from String to UUID, I don't get the exception, but the migrationBlock is still not called and my app crashes for other reasons since it's expecting that field to be populated.
I found an error that would produce the issue that you report. It is fixed by #8046. But it would require that no migration function is supplied as the codeline with the assertion is only hit if there is no migration function (or if the SchemaMode is additive changes only). So in order to fix your issue, I would look for ways that the migration function could be missing in your application code.
SDK and version
SDK : Swift
Version: 10.33.0
Observations
Crash log / stacktrace
Steps & Code to Reproduce
I changed my primary key type from String to UUID
OLD:
NEW:
configuration:
The text was updated successfully, but these errors were encountered: