[OCaml] High Intensity Training Online
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, so applying
5
on connect runs only the migrations the file is missing and never repeats
6
one. Every statement still uses [IF NOT EXISTS], so a database created by an
7
earlier, ledger-less build stays safe.
8
9
Includes the [dream_session] table {!Dream.sql_sessions} expects. *)
10
11
type migration = { version : int; name : string; statements : string list }
12
(** One migration: a version, a human name, and the ordered statements it runs.
13
*)
14
15
val migrations : migration list
16
(** Every migration, in ascending version order. *)
17
18
val apply : (module Caqti_lwt.CONNECTION) -> (unit, Caqti_error.t) result Lwt.t
19
(** Create the ledger, then apply every migration not yet recorded, each inside
20
a transaction. Idempotent across reconnects. *)
21
22
val statements : string list
23
(** Every migration's statements, in order, exposed for documentation and tests.
24
*)
25