aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-04 15:11:21 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-04 15:11:21 +0100
commitf68166514f5aeea3c8af0e47c056bb7a090ee46f (patch)
tree1a2b8f26408bdbc3aa2f8b5ff9719411ff25f118 /guix-data-service
parent48673b32cbe05145ddf9dd9453937ace53574bed (diff)
downloaddata-service-f68166514f5aeea3c8af0e47c056bb7a090ee46f.tar
data-service-f68166514f5aeea3c8af0e47c056bb7a090ee46f.tar.gz
Actually delete more of the data for a revision
Previously the package_derivations table wasn't considered, which would mean derivations would still be referenced. This commit fixes that, along with also deleting unreferenced entries in some linter related tables.
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/data-deletion.scm42
1 files changed, 41 insertions, 1 deletions
diff --git a/guix-data-service/data-deletion.scm b/guix-data-service/data-deletion.scm
index 775db6b..7387802 100644
--- a/guix-data-service/data-deletion.scm
+++ b/guix-data-service/data-deletion.scm
@@ -33,6 +33,42 @@
delete-unreferenced-derivations))
(define (delete-guix-revisions conn git-repository-id commits)
+ (define (delete-unreferenced-package-derivations)
+ (exec-query
+ conn
+ "
+DELETE FROM package_derivations
+WHERE NOT EXISTS (
+ SELECT 1
+ FROM guix_revision_package_derivations
+ WHERE guix_revision_package_derivations.package_derivation_id =
+ package_derivations.id
+)"))
+
+ (define (delete-unreferenced-lint-warnings)
+ (exec-query
+ conn
+ "
+DELETE FROM lint_warnings
+WHERE NOT EXISTS (
+ SELECT 1
+ FROM guix_revision_lint_warnings
+ WHERE guix_revision_lint_warnings.lint_warning_id =
+ lint_warnings.id
+)"))
+
+ (define (delete-unreferenced-lint-checkers)
+ (exec-query
+ conn
+ "
+DELETE FROM lint_checkers
+WHERE NOT EXISTS (
+ SELECT 1
+ FROM guix_revision_lint_checkers
+ WHERE guix_revision_lint_checkers.lint_checker_id =
+ lint_checkers.id
+)"))
+
(let ((guix-revision-ids
(map
car
@@ -96,7 +132,11 @@ AND id NOT IN (
INNER JOIN git_branches ON
git_branches.commit = guix_revisions.commit AND
git_branches.git_repository_id = guix_revisions.git_repository_id
-)")))))
+)"))
+
+ (delete-unreferenced-package-derivations)
+ (delete-unreferenced-lint-warnings)
+ (delete-unreferenced-lint-checkers))))
(define (delete-revisions-from-branch conn git-repository-id branch-name commits)
(define (delete-jobs conn)