Search code examples
iossqlsqlitecore-datajournaling

Prepopulated Core Data SQL store with new Write-Ahead Log (WAL) journaling


I would like to ship my app with an SQL datastore, but now, since Apple has introduced a WAL journaling, that makes 3 files instead of one, so I wonder if I should ship all 3 of them, or I can try to force SQL to make a checkpoint, merging it all into one .sql file.

I would really like to go with this new iOS 7 feature, so going back to rollback journaling is not a way for me.


Solution

  • To force SQLite to make a checkpoint, execute PRAGMA wal_checkpoint.

    Alternatively, ship the database with journal_mode = DELETE, and change the mode after the file has been installed.

    In any case, there is no problem with just shipping all files. (The -shm file does not contain permanent data and could be ignored.)