Add a helper procedure to delete data for deleted branches
This commit is contained in:
parent
9c72fc23dc
commit
f11421824d
1 changed files with 26 additions and 1 deletions
|
|
@ -20,7 +20,8 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
#:use-module (guix-data-service database)
|
#:use-module (guix-data-service database)
|
||||||
#:export (delete-data-for-branch))
|
#:export (delete-data-for-branch
|
||||||
|
delete-data-for-all-deleted-branches))
|
||||||
|
|
||||||
(define (delete-data-for-branch conn git-repository-id branch-name)
|
(define (delete-data-for-branch conn git-repository-id branch-name)
|
||||||
(define commits
|
(define commits
|
||||||
|
|
@ -179,6 +180,30 @@ SELECT DISTINCT name
|
||||||
FROM git_branches
|
FROM git_branches
|
||||||
WHERE git_repository_id = 1 AND name != 'master'"))))))
|
WHERE git_repository_id = 1 AND name != 'master'"))))))
|
||||||
|
|
||||||
|
(define (delete-data-for-all-deleted-branches)
|
||||||
|
(with-postgresql-connection
|
||||||
|
"data-deletion"
|
||||||
|
(lambda (conn)
|
||||||
|
(for-each
|
||||||
|
(match-lambda
|
||||||
|
((name git-repository-id)
|
||||||
|
(simple-format #t "deleting data for ~A (~A)\n"
|
||||||
|
name git-repository-id)
|
||||||
|
(delete-data-for-branch conn
|
||||||
|
(string->number git-repository-id)
|
||||||
|
name)))
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
"
|
||||||
|
SELECT name, git_repository_id
|
||||||
|
FROM (
|
||||||
|
SELECT DISTINCT ON (name, git_repository_id)
|
||||||
|
name, git_repository_id, commit
|
||||||
|
FROM git_branches
|
||||||
|
ORDER BY git_repository_id, name, datetime DESC
|
||||||
|
) AS git_branches_latest_revision
|
||||||
|
WHERE commit = ''")))))
|
||||||
|
|
||||||
(define (delete-unreferenced-derivations)
|
(define (delete-unreferenced-derivations)
|
||||||
(define (maybe-delete-derivation conn id file-name)
|
(define (maybe-delete-derivation conn id file-name)
|
||||||
(match (map
|
(match (map
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue