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 ===
Can someone explain the purpose of ACHANGE in CoreData database?
Is there a way to revert the Cloudkit CoreData to a specific Transaction History Token (or to the commit before a specific ACHANGE)?
Are the contents permanently deleted from the database after:
context.performAndWait {
//... fetch object
context.delete(object)
do {
try contex.save()
} catch {
print(error)
}
}
================

