Merge pull request 'Fixed that Builder_db_app.job_remove didn't take all related tables into account' (#89) from 20220222_fix_job_remove_and_added_helper_for_printing_db_id into main

Reviewed-on: https://git.robur.io/robur/builder-web/pulls/89
This commit is contained in:
Reynir Björnsson 2022-02-22 13:53:22 +00:00
commit 4d60b9aa48
4 changed files with 20 additions and 0 deletions

View file

@ -164,6 +164,8 @@ let job_remove () datadir jobname =
(Ok ())
builds
in
let* () = Db.exec Builder_db.Access_list.remove_by_job job_id in
let* () = Db.exec Builder_db.Job_tag.remove_by_job job_id in
let* () = Db.exec Builder_db.Job.remove job_id in
Db.commit ()
in

View file

@ -152,6 +152,12 @@ module Job_tag = struct
Caqti_type.(tup2 (id `tag) (id `job))
Caqti_type.string
"SELECT value FROM job_tag WHERE tag = ? AND job = ?"
let remove_by_job =
Caqti_request.exec
(id `job)
"DELETE FROM job_tag WHERE job = ?"
end
module Build_artifact = struct
@ -649,6 +655,11 @@ module Access_list = struct
Caqti_type.(tup2 (id `user) (id `job))
"DELETE FROM access_list WHERE user = ? AND job = ?"
let remove_by_job =
Caqti_request.exec
(id `job)
"DELETE FROM access_list WHERE job = ?"
let remove_all_by_username =
Caqti_request.exec
Caqti_type.string

View file

@ -8,6 +8,7 @@ module Rep : sig
size : int;
}
val id_to_int64 : 'a id -> int64
val untyped_id : untyped_id Caqti_type.t
val id : 'a -> 'a id Caqti_type.t
val uuid : Uuidm.t Caqti_type.t
@ -74,6 +75,8 @@ module Job_tag : sig
([`tag] id * string * [`job] id, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
val get_value :
([`tag] id * [`job] id, string, [< `Many | `One | `Zero > `Zero `One ]) Caqti_request.t
val remove_by_job :
([`job] id, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
end
module Build_artifact : sig
@ -176,6 +179,8 @@ module Access_list : sig
([`user] id * [`job] id, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
val remove :
([`user] id * [`job] id, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
val remove_by_job :
([`job] id, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
val remove_all_by_username :
(string, unit, [< `Many | `One | `Zero > `Zero ]) Caqti_request.t
end

View file

@ -26,6 +26,8 @@ type 'a id = untyped_id
let id (_ : 'a) : 'a id Caqti_type.t = untyped_id
let any_id : 'a id Caqti_type.t = untyped_id
let id_to_int64 (id : 'a id) : int64 = id
type file = {
filepath : Fpath.t;
localpath : Fpath.t;