Menu

Moving a SQLite database aside without losing its WAL
📰

Moving a SQLite database aside without losing its WAL

DEV Community: sql·Darkø Tasevski·about 18 hours ago
#NVTpN3v8
#devtosql#devto#dev#database#store
Long article (1715 words) — no AI summary yet.
Reading 0:00
15s threshold

This one is a note about SQLite in WAL mode, and about a recovery path I wrote for a small on-device store in an iOS app I'm working on, which looked fine in review and still managed to lose a committed transaction in a test.

The setup

The app keeps a few settings in a SQLite database opened through GRDB , in WAL mode, which means that on disk the database is three files and not one:

store/ store.sqlite # the database itself store.sqlite-wal # committed transactions not yet copied into the database store.sqlite-shm # shared-memory index for the WAL

Enter fullscreen mode

Exit fullscreen mode

When the app opens the store and finds something it can't trust (it was written by a different install, or it's corrupt), it doesn't delete anything.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.