Delete builds for unreferenced derivations
This commit is contained in:
parent
52a23a5333
commit
5b13ee2251
1 changed files with 34 additions and 0 deletions
|
|
@ -268,6 +268,36 @@ FROM (
|
||||||
WHERE commit = ''")))))
|
WHERE commit = ''")))))
|
||||||
|
|
||||||
(define (delete-unreferenced-derivations)
|
(define (delete-unreferenced-derivations)
|
||||||
|
(define (delete-builds-for-derivation-output-details-set
|
||||||
|
conn
|
||||||
|
derivation-output-details-set-id)
|
||||||
|
(let ((build-ids
|
||||||
|
(map car
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
"
|
||||||
|
SELECT id
|
||||||
|
FROM builds
|
||||||
|
WHERE derivation_output_details_set_id = $1"
|
||||||
|
derivation-output-details-set-id))))
|
||||||
|
|
||||||
|
(unless (null? build-ids)
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
(string-append
|
||||||
|
"
|
||||||
|
DELETE FROM build_status WHERE build_id IN ("
|
||||||
|
(string-join build-ids ",")
|
||||||
|
")"))
|
||||||
|
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
(string-append
|
||||||
|
"
|
||||||
|
DELETE FROM builds WHERE id IN ("
|
||||||
|
(string-join build-ids ",")
|
||||||
|
")")))))
|
||||||
|
|
||||||
(define (maybe-delete-derivation conn id file-name)
|
(define (maybe-delete-derivation conn id file-name)
|
||||||
(match (map
|
(match (map
|
||||||
car
|
car
|
||||||
|
|
@ -348,6 +378,10 @@ WHERE derivation_id = $1"
|
||||||
|
|
||||||
(when (<= (string->number count)
|
(when (<= (string->number count)
|
||||||
1)
|
1)
|
||||||
|
(delete-builds-for-derivation-output-details-set
|
||||||
|
conn
|
||||||
|
derivation-output-details-set-id)
|
||||||
|
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue