-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fail to migrate BSManagedDocuments when -wal and -shm are present #42
Comments
Hi Motti, I don't provide any hooks for migration for BSManagedDocument since it's highly app-dependent how you want to handle the migration. For example, my approach would likely be to subclass The |
While I'd do the same for robust document versioning, I need to update my model for technical reasons, and migration should be completely automatic and transparent to the user. I do it very simply. In my Document subclass of BSManagedDocument, I override
Providing all the migration machinery in my model and code. It worked for me until now (7 migrations) but now I face real hard time with the 8th. Few relations became required (non-optional to-one relation). My old documents had "orphan" entities. My migrations fail, and I decided to cleanup all orphans BEFORE attempting the migration, to find the source of the problem. So I cleanup (using the old model) and save. CoreDataEditor allows me to look into the clean DB - and it is good. No orphans. BUT, when I try to migrate, the migration process finds orphaned entities that have already been deleted!!! Even worse, it complains about more instances of entities than exist in the database! It gives me exact ObjectID's that don't exist. It's driving me mad, and I just can't make it WHERE does Core Data bring in the persistent store and data anymore. The errors all indicate the good, clean persistent store. Can you hint? Can it be related to the way BSManagedDocument does its background writes, and autosave-in-place? or maybe application saved-states are my problem? the -wal? the -shm? |
I can't hint because I honestly haven't a clue what's happening. BSManagedDocument provides a pretty standard Core Data stack, and integrates that with Apple's document-handling logic. If you're doing something custom, I'm afraid you need to understand what's going on and figure it out for yourself. |
I need to (custom) migrate my documents upon open.
After much struggle I got it to work - with one last problem. If my document packages contain, persistentStore-wal and persistentStore-shm files, the migration "succeeds" but fails to save.
In one place in the internet I read that CoreData might mistake the old -wal files of the old persistent store for new model - and fail saving.
First, I don't understand why -wal and -sha files exist after I save a document.
Second, doesn't BSManagedDocument provide some temporary path for the migration, or alternatively help with a hook for this? I do not really understand the migration process, but I presume the new persistent store finally replaces the old one, and the old one gets deleted in the end - so why aren't the -wal and shm files deleted with it?
A few words about those 2 files will also be very helpful. When are they safe to delete etc.
The text was updated successfully, but these errors were encountered: