2021-06-10 10:08:14 +00:00
|
|
|
let old_version = 3L and new_version = 3L
|
|
|
|
let identifier = "2021-04-27"
|
|
|
|
let migrate_doc = "add index idx_build_job_start on build"
|
|
|
|
let rollback_doc = "rollback index idx_build_job_start on build"
|
|
|
|
|
2021-10-20 09:10:43 +00:00
|
|
|
open Grej.Infix
|
2021-04-29 13:16:19 +00:00
|
|
|
|
2021-06-01 15:43:55 +00:00
|
|
|
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
2021-04-29 13:16:19 +00:00
|
|
|
let idx_build_job_start =
|
|
|
|
Caqti_request.exec ~oneshot:true
|
|
|
|
Caqti_type.unit
|
|
|
|
"CREATE INDEX idx_build_job_start ON build(job, start_d DESC, start_ps DESC)"
|
|
|
|
in
|
|
|
|
let rm_job_build_idx =
|
|
|
|
Caqti_request.exec ~oneshot:true
|
|
|
|
Caqti_type.unit
|
|
|
|
"DROP INDEX IF EXISTS job_build_idx"
|
|
|
|
in
|
2021-06-10 10:08:14 +00:00
|
|
|
Grej.check_version ~user_version:old_version (module Db) >>= fun () ->
|
2021-04-29 13:16:19 +00:00
|
|
|
Db.exec rm_job_build_idx () >>= fun () ->
|
|
|
|
Db.exec idx_build_job_start ()
|
|
|
|
|
2021-06-01 15:43:55 +00:00
|
|
|
let rollback _datadir (module Db : Caqti_blocking.CONNECTION) =
|
2021-04-29 13:16:19 +00:00
|
|
|
let job_build_idx =
|
|
|
|
Caqti_request.exec ~oneshot:true
|
|
|
|
Caqti_type.unit
|
|
|
|
"CREATE INDEX job_build_idx ON build(job)"
|
|
|
|
in
|
|
|
|
let rm_idx_build_job_start =
|
|
|
|
Caqti_request.exec ~oneshot:true
|
|
|
|
Caqti_type.unit
|
|
|
|
"DROP INDEX IF EXISTS idx_build_job_start"
|
|
|
|
in
|
2021-06-10 10:08:14 +00:00
|
|
|
Grej.check_version ~user_version:new_version (module Db) >>= fun () ->
|
2021-04-29 13:16:19 +00:00
|
|
|
Db.exec rm_idx_build_job_start () >>= fun () ->
|
|
|
|
Db.exec job_build_idx ()
|