Add migration for modified index

This commit is contained in:
Reynir Björnsson 2023-09-11 12:31:11 +02:00
parent 3b98605fb7
commit 3fe8bcb997
3 changed files with 28 additions and 1 deletions

View file

@ -179,6 +179,7 @@ let () =
[ f20210910 ]; [ f20210910 ];
actions (module M20211105); actions (module M20211105);
actions (module M20220509); actions (module M20220509);
actions (module M20230911);
]) ])
|> Cmd.eval |> Cmd.eval
|> exit |> exit

View file

@ -0,0 +1,26 @@
let new_version = 17L and old_version = 16L
and identifier = "2023-09-11"
and migrate_doc = "index failed builds on main binary is null"
and rollback_doc = "index failed builds on exit code"
open Grej.Syntax
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
let* () = Grej.check_version ~user_version:old_version (module Db) in
let* () =
Db.exec (Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) \
WHERE main_binary IS NULL")
()
in
Db.exec (Grej.set_version new_version) ()
let rollback _datadir (module Db : Caqti_blocking.CONNECTION) =
let* () = Grej.check_version ~user_version:new_version (module Db) in
let* () =
Db.exec (Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) \
WHERE result_code <> 0")
()
in
Db.exec (Grej.set_version old_version) ()

View file

@ -5,7 +5,7 @@ open Caqti_request.Infix
let application_id = 1234839235l let application_id = 1234839235l
(* Please update this when making changes! *) (* Please update this when making changes! *)
let current_version = 16L let current_version = 17L
type 'a id = 'a Rep.id type 'a id = 'a Rep.id