Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mibrahim025 opened this issue Mar 15, 2023 · 1 comment

Comments

@mibrahim025
Copy link

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?

@mibrahim025 mibrahim025 changed the title "Migration succeeds when app is offline but when becomes online, local objects are replaced with iCloud objects due to which local objects loss data Migration succeeds when app is offline but when becomes online, local objects are replaced with iCloud objects due to which local objects loss data Mar 15, 2023
@mibrahim025 mibrahim025 changed the title Migration succeeds when app is offline but when becomes online, local objects are replaced with iCloud objects due to which local objects loss data Migration succeeds when app is offline but when becomes online, local objects are replaced with iCloud objects due to which local objects lose data Mar 15, 2023
@rosday
Copy link

rosday commented May 5, 2023

I am having a similar problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants