0

A user has accidentally deleted a root record that removes all data from the user. The data is stored in Cloudkit CoreData with Transaction History enabled.

I have noticed in the CoreData database that there is a ACHANGE record. And every NSManagedObject save or delete commit will create 3 new ACHANGE records to the CoreData database as follows:

  • ZENTITY 1, 9, 18 which refers to the Root, Child and Grandchild Entities).
  • ZCHANGETYPE seems to indicate - 0:Create; 1:Update; 2:Delete
  • In the respective ZENTITY (e.g. 18), the corresponding ZENTITYPK (e.g. 15) is PERMANENTLY DELETED from the database and a new record of the ZENTITY 18 will take the next value ZENTITYPK 16 (See image).

=== QUESTIONS ===

  1. Can someone explain the purpose of ACHANGE in CoreData database?

  2. Is there a way to revert the Cloudkit CoreData to a specific Transaction History Token (or to the commit before a specific ACHANGE)?

  3. Are the contents permanently deleted from the database after:

context.performAndWait {
    //... fetch object
    context.delete(object)
    do {
        try contex.save()
    } catch {
        print(error)
    }
}

================

enter image description here

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.