caiyue1993/IceCream

Migration succeeds when app is offline but when becomes online, local objects are replaced with iCloud objects due to which local objects lose data

mibrahim025 opened this issue · 1 comments

I had recipient and phonenumber objects like these.

@objc class Recipient: Object {
@persisted(primaryKey: true) var rec_id = ""
@persisted var firstName = ""
@persisted var lastName = ""
@persisted var phoneNumbersList = List()
@persisted var email = ""
@persisted var isDeleted = false // IceCream requirement
}

@objc class PhoneNumber: Object {
@persisted(primaryKey: true) var id = ""
@persisted var number = ""
@persisted var isDeleted = false // IceCream requirement
}

I changed the schema to this. i.e. removed the phoneNumberList property and added phoneNumber as string only.

@objc public class Recipient: Object {
@persisted(primaryKey: true) var rec_id = ""
@persisted var firstName = ""
@persisted var lastName = ""
@persisted var phoneNumber = ""
@persisted var email = ""
@persisted public var isDeleted = false // IceCream requirement
}

Old records on icloud have phonenumberList property populated and phoneNumber property is nil.

Now in the new version of the app, i have done migration correctly and it works but when the app is offline. When it becomes online, the migrated records again are replaced with the fetched records from icloud whose phoneNumber property is nil and my app starts missing phoneNumbers. How can i solve this?

rosday commented

I am having a similar problem