Core Data - Migration Manager fails with journal_mode = WAL

Originator:pbendersky
Number:rdar://13982460 Date Originated:24-May-2013
Status:Open Resolved:
Product:iOS SDK Product Version:6.1
Classification:Serious Bug Reproducible:
 
Summary:
If a Core Data stack is set with the options NSSQLitePragmasOption: @{@"journal_mode": @"WAL"} and you need to run a migration that requires a Migration Manager, the resulting database will be corrupted and unreadable by Core Data.

Steps to Reproduce:
1. Create a project using the Core Data template.
2. Change the initialization to include these parameters when adding the NSPersistentStore
    NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption:@YES,
                              NSInferMappingModelAutomaticallyOption:@YES,
                              NSSQLitePragmasOption: @{@"journal_mode": @"WAL"}
                              };
3. Run the app and add some records.
4. Add a new model version.
5. Add a new migration that uses a Migration Manager, and code it.
6. Run the new app.

Expected Results:
Perfectly functional app with migrated data.

Actual Results:
Empty DB and the app doesn't work any longer (can't add new records)

Notes:
I'm attaching a sample project. In there you can see four folders:
- v1: Initial version, almost as generated by the Xcode template.
- v1-Documents: The SQLite DB copied from the simulator after running the app.
- v2: A failing version of the app.
- v2-Workaround: A workaround that sets the journal_mode to DELETE, migrates, and reverts to WAL afterwards.

Comments

Yep.

Ran into this as well. Thanks for reporting it - will dup.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!