; "Litestream requires periodic but short write locks on the database when
;  checkpointing occurs":
; https://litestream.io/tips/#busy-timeout
PRAGMA busy_timeout = 5000;

; "Litestream only works with the SQLite WAL journaling mode":
; https://litestream.io/tips/#wal-journal-mode
PRAGMA journal_mode = WAL;

; "(...) change the synchronous mode to NORMAL (it typically defaults to FULL)":
; https://litestream.io/tips/#synchronous-pragma
; "WAL mode is safe from corruption with synchronous=NORMAL":
; https://www.sqlite.org/pragma.html#pragma_synchronous
PRAGMA synchronous = NORMAL;

; "(...) can perform a checkpoint in between Litestream-initiated checkpoints
;  and cause Litestream to miss a WAL file":
; https://litestream.io/tips/#disable-autocheckpoints-for-high-write-load-servers
PRAGMA wal_autocheckpoint = 0;

; "This pragma does a low-level formatting and consistency check of the
;  database":
; https://www.sqlite.org/pragma.html#pragma_integrity_check
PRAGMA integrity_check;

; "The foreign_key_check pragma checks the database, or the table called
   \"table-name\", for foreign key constraints that are violated":
; https://www.sqlite.org/pragma.html#pragma_foreign_key_check
PRAGMA foreign_key_check;


CREATE TABLE IF NO EXISTS migrations (
	name TEXT PRIMARY KEY
);
