From 078516e0ab67916b8b428580c7deaf0c12097e13 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 13 Feb 2023 19:26:44 +0000 Subject: Improve dropping package_derivation_by_guix_revision_range partitions --- guix-data-service/data-deletion.scm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/guix-data-service/data-deletion.scm b/guix-data-service/data-deletion.scm index 6794bea..a91d02b 100644 --- a/guix-data-service/data-deletion.scm +++ b/guix-data-service/data-deletion.scm @@ -24,6 +24,7 @@ #:use-module (fibers) #:use-module (guix-data-service utils) #:use-module (guix-data-service database) + #:use-module (guix-data-service model git-branch) #:use-module (guix-data-service model package-derivation-by-guix-revision-range) #:export (delete-guix-revisions delete-data-for-branch @@ -213,18 +214,16 @@ WHERE id IN ( (delete-from-git-commits conn) (delete-jobs conn) - (exec-query - conn - " -DELETE FROM package_derivations_by_guix_revision_range -WHERE git_branch_id IN ( - SELECT id - FROM git_branches - WHERE git_repository_id = $1 AND - name = $2 -)" - (list (number->string git-repository-id) - branch-name)) + (let ((git-branch-id + (git-branch-for-repository-and-name conn + git-repository-id + branch-name))) + (exec-query + conn + (string-append + " +DROP TABLE package_derivations_by_guix_revision_range_git_branch_" + (number->string git-branch-id) ";"))) (delete-guix-revisions conn git-repository-id commits)))) -- cgit v1.2.3