View raw

1 (** Versioned schema migrations for the SQLite store. 2 3 Each migration is a numbered, named set of statements. A [schema_migrations] 4 ledger records which versions a database file already carries. On connect, 5 hito runs only the migrations the file is missing and never repeats one. 6 Every statement still uses [IF NOT EXISTS], so a database created by an 7 earlier, ledger-less build stays safe. 8 9 Includes a [dream_session] table from when sessions were stored in SQLite. 10 Sessions now live in a signed cookie; the table is retained so an existing 11 file keeps its rows, and is otherwise unused. *) 12 13 type migration = { version : int; name : string; statements : string list } 14 (** One migration: a version, a human name, and the ordered statements it runs. 15 *) 16 17 val migrations : migration list 18 (** Every migration, in ascending version order. *) 19 20 val apply : (module Caqti_lwt.CONNECTION) -> (unit, Caqti_error.t) result Lwt.t 21 (** Create the ledger, then apply every migration not yet recorded, each inside 22 a transaction. Idempotent across reconnects. *) 23 24 val statements : string list 25 (** Every migration's statements, in order, exposed for documentation and tests. 26 *) 27