Add delete-revisions-from-branch-except-most-recent-n
This commit is contained in:
parent
992a0af63e
commit
65e8bf3f8d
1 changed files with 32 additions and 1 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
#:use-module (guix-data-service database)
|
#:use-module (guix-data-service database)
|
||||||
#:use-module (guix-data-service model package-derivation-by-guix-revision-range)
|
#:use-module (guix-data-service model package-derivation-by-guix-revision-range)
|
||||||
#:export (delete-data-for-branch
|
#:export (delete-data-for-branch
|
||||||
|
delete-revisions-from-branch-except-most-recent-n
|
||||||
delete-data-for-all-deleted-branches))
|
delete-data-for-all-deleted-branches))
|
||||||
|
|
||||||
(define (delete-revisions-from-branch conn git-repository-id branch-name commits)
|
(define (delete-revisions-from-branch conn git-repository-id branch-name commits)
|
||||||
|
|
@ -114,7 +115,7 @@ WHERE guix_revisions.git_repository_id = "
|
||||||
(for-each (lambda (guix-revision-id)
|
(for-each (lambda (guix-revision-id)
|
||||||
(delete-guix-revision-package-derivation-entries
|
(delete-guix-revision-package-derivation-entries
|
||||||
conn
|
conn
|
||||||
git-repository-id
|
(number->string git-repository-id)
|
||||||
guix-revision-id
|
guix-revision-id
|
||||||
branch-name))
|
branch-name))
|
||||||
guix-revision-ids)
|
guix-revision-ids)
|
||||||
|
|
@ -169,6 +170,36 @@ WHERE git_repository_id = $1 AND name = $2"
|
||||||
branch-name
|
branch-name
|
||||||
commits))
|
commits))
|
||||||
|
|
||||||
|
(define (delete-revisions-from-branch-except-most-recent-n conn
|
||||||
|
git-repository-id
|
||||||
|
branch-name
|
||||||
|
n)
|
||||||
|
(define commits
|
||||||
|
(map car
|
||||||
|
(exec-query conn
|
||||||
|
"
|
||||||
|
SELECT commit
|
||||||
|
FROM git_branches
|
||||||
|
WHERE git_repository_id = $1 AND name = $2
|
||||||
|
ORDER BY datetime DESC
|
||||||
|
OFFSET $3"
|
||||||
|
(list (number->string git-repository-id)
|
||||||
|
branch-name
|
||||||
|
(number->string n)))))
|
||||||
|
|
||||||
|
(unless (null? commits)
|
||||||
|
(simple-format #t "deleting ~A commits\n" (length commits))
|
||||||
|
(delete-revisions-from-branch conn
|
||||||
|
git-repository-id
|
||||||
|
branch-name
|
||||||
|
commits)
|
||||||
|
|
||||||
|
(simple-format #t "repopulating package_derivations_by_guix_revision_range\n")
|
||||||
|
(insert-guix-revision-package-derivation-entries conn
|
||||||
|
(number->string
|
||||||
|
git-repository-id)
|
||||||
|
branch-name)))
|
||||||
|
|
||||||
(define (delete-data-for-all-branches-but-master)
|
(define (delete-data-for-all-branches-but-master)
|
||||||
(with-postgresql-connection
|
(with-postgresql-connection
|
||||||
"data-deletion"
|
"data-deletion"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue