Handle jobs without successful build in migrations
The migrations migrate-2021-06-29 and migrate-2021-06-30 would not apply if a job exists without any successful build. Now the migrations script silently skips jobs without succesful builds.
This commit is contained in:
parent
bd0ab7f554
commit
37e68f91f4
2 changed files with 37 additions and 32 deletions
|
@ -34,7 +34,7 @@ let jobs =
|
|||
"SELECT id FROM job"
|
||||
|
||||
let latest_successful_build =
|
||||
Caqti_request.find
|
||||
Caqti_request.find_opt
|
||||
Builder_db.Rep.id
|
||||
Builder_db.Rep.id
|
||||
{| SELECT b.id
|
||||
|
@ -138,7 +138,10 @@ let migrate datadir (module Db : Caqti_blocking.CONNECTION) =
|
|||
Db.find find_tag "description" >>= fun descr_id ->
|
||||
Db.collect_list jobs () >>= fun jobs ->
|
||||
Grej.list_iter_result (fun job ->
|
||||
Db.find latest_successful_build job >>= fun build ->
|
||||
Db.find_opt latest_successful_build job >>= function
|
||||
| None ->
|
||||
Ok ()
|
||||
| Some build ->
|
||||
Db.collect_list build_artifacts build >>= fun artifacts ->
|
||||
List.fold_left (fun acc (fpath, lpath) ->
|
||||
acc >>= fun acc ->
|
||||
|
|
|
@ -10,7 +10,7 @@ let jobs =
|
|||
"SELECT id FROM job"
|
||||
|
||||
let latest_successful_build =
|
||||
Caqti_request.find
|
||||
Caqti_request.find_opt
|
||||
Builder_db.Rep.id
|
||||
Builder_db.Rep.id
|
||||
{| SELECT b.id
|
||||
|
@ -63,7 +63,9 @@ let migrate datadir (module Db : Caqti_blocking.CONNECTION) =
|
|||
Db.find find_tag "readme.md" >>= fun readme_id ->
|
||||
Db.collect_list jobs () >>= fun jobs ->
|
||||
Grej.list_iter_result (fun job ->
|
||||
Db.find latest_successful_build job >>= fun build ->
|
||||
Db.find_opt latest_successful_build job >>= function
|
||||
| None -> Ok ()
|
||||
| Some build ->
|
||||
Db.collect_list build_artifacts build >>= fun artifacts ->
|
||||
List.fold_left (fun acc (fpath, lpath) ->
|
||||
acc >>= fun acc ->
|
||||
|
|
Loading…
Reference in a new issue