2021-06-25 10:26:03 +00:00
|
|
|
let new_version = 8L and old_version = 7L
|
|
|
|
let identifier = "2021-06-25"
|
|
|
|
let migrate_doc = "drop build_file table"
|
|
|
|
let rollback_doc = "recreate build_file table"
|
|
|
|
|
2022-04-04 16:30:21 +00:00
|
|
|
open Grej.Infix
|
|
|
|
|
2021-06-25 10:26:03 +00:00
|
|
|
let build_file =
|
2022-04-04 16:30:21 +00:00
|
|
|
Caqti_type.unit ->. Caqti_type.unit @@
|
|
|
|
{| CREATE TABLE build_file (
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
|
|
filepath TEXT NOT NULL, -- the path as in the build
|
|
|
|
localpath TEXT NOT NULL, -- local path to the file on disk
|
|
|
|
sha256 BLOB NOT NULL,
|
|
|
|
size INTEGER NOT NULL,
|
|
|
|
build INTEGER NOT NULL,
|
2021-06-25 10:26:03 +00:00
|
|
|
|
2022-04-04 16:30:21 +00:00
|
|
|
FOREIGN KEY(build) REFERENCES build(id),
|
|
|
|
UNIQUE(build, filepath)
|
|
|
|
)
|
|
|
|
|}
|
2021-06-25 10:26:03 +00:00
|
|
|
|
|
|
|
let drop_build_file =
|
2022-04-04 16:30:21 +00:00
|
|
|
Caqti_type.unit ->. Caqti_type.unit @@
|
|
|
|
"DROP TABLE build_file"
|
2021-06-25 10:26:03 +00:00
|
|
|
|
|
|
|
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
|
|
|
Grej.check_version ~user_version:old_version (module Db) >>= fun () ->
|
|
|
|
Db.exec drop_build_file () >>= fun () ->
|
|
|
|
Db.exec (Grej.set_version new_version) ()
|
|
|
|
|
|
|
|
let rollback _datadir (module Db : Caqti_blocking.CONNECTION) =
|
|
|
|
Grej.check_version ~user_version:new_version (module Db) >>= fun () ->
|
|
|
|
Db.exec build_file () >>= fun () ->
|
|
|
|
Db.exec (Grej.set_version old_version) ()
|