Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data WAL mode not persisting changes to .db, only .db-wal and .db-shm

So, I have been using MagicalRecord to develop an iPad app, and recently after moving to an auto-migrating store I have been experiencing some issues. I need to sync my .db file from one device over to another, so I need all of the data to be in the .db, but it seems like with WAL journaling mode enabled (the default for Magical Record auto-migrating stores) no matter how I save it only persists the changes to either the .db-wal or the .db-shm files. I switched to a normal sqlite store and everything worked fine. So, my question is, with WAL journaling enabled do I need to do anything special to actually get Core Data to save to the main database, or will I just have to disable it?

like image 836
AengusMcMillin Avatar asked Oct 04 '22 00:10

AengusMcMillin


1 Answers

Change the journal mode. You have the Magical Record source, after all. Change the SQLite journal mode to DELETE, and the journal mode will be deleted after every transaction. Disabling journalling is a really bad idea, don't do that. But using a different mode should be fine.

Core Data does not offer any API for manipulating the journal once the persistent store is open. SQLite is an implementation detail, and Core Data doesn't expose the internal SQLite details. The closest you can get is the options parameter when setting up the Core Data stack, which is where you can change the journal mode (and where MR changes it).

like image 77
Tom Harrington Avatar answered Oct 07 '22 19:10

Tom Harrington