diff options
author | Christopher Baines <mail@cbaines.net> | 2021-02-02 23:36:56 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-02-02 23:36:56 +0000 |
commit | 7fbcb3a3c26906ee130bcc64e88ea7a2b390de2c (patch) | |
tree | 1b1f55d68015f18fabea46865c3762a61d150691 /guix-data-service/model | |
parent | 6195d7b18f913d0f8f5540858676b7d6c45196b7 (diff) | |
download | data-service-7fbcb3a3c26906ee130bcc64e88ea7a2b390de2c.tar data-service-7fbcb3a3c26906ee130bcc64e88ea7a2b390de2c.tar.gz |
Store channel instance derivations in a separate transaction
This means that these derivations are stored, even if a later part of the
process fails. Having the channel instance derivations stored might help work
out why the failure occurred, or better display information about it.
Diffstat (limited to 'guix-data-service/model')
-rw-r--r-- | guix-data-service/model/channel-instance.scm | 16 | ||||
-rw-r--r-- | guix-data-service/model/guix-revision.scm | 13 |
2 files changed, 21 insertions, 8 deletions
diff --git a/guix-data-service/model/channel-instance.scm b/guix-data-service/model/channel-instance.scm index 35a4879..956018e 100644 --- a/guix-data-service/model/channel-instance.scm +++ b/guix-data-service/model/channel-instance.scm @@ -24,6 +24,7 @@ #:use-module (guix-data-service model utils) #:use-module (guix-data-service model derivation) #:export (insert-channel-instances + channel-instances-exist-for-guix-revision? select-channel-instances-for-guix-revision)) (define (insert-channel-instances conn @@ -52,6 +53,21 @@ VALUES " ", ")))) #t) +(define (channel-instances-exist-for-guix-revision? conn commit-hash) + (define query + " +SELECT EXISTS( + SELECT 1 + FROM channel_instances + INNER JOIN guix_revisions + ON guix_revisions.id = channel_instances.guix_revision_id + WHERE guix_revisions.commit = $1 +)") + + (let ((result (caar + (exec-query conn query (list commit-hash))))) + (string=? result "t"))) + (define (select-channel-instances-for-guix-revision conn commit-hash) (define query diff --git a/guix-data-service/model/guix-revision.scm b/guix-data-service/model/guix-revision.scm index ecc3cf0..4f5ed6d 100644 --- a/guix-data-service/model/guix-revision.scm +++ b/guix-data-service/model/guix-revision.scm @@ -46,16 +46,13 @@ id) (() #f))) -(define (insert-guix-revision conn git-repository-id commit store_path) +(define (insert-guix-revision conn git-repository-id commit) (define insert - (string-append "INSERT INTO guix_revisions " - "(git_repository_id, commit, store_path) VALUES " - "(" git-repository-id ", '" - commit "', '" - store_path "') " - "RETURNING id;")) + " +INSERT INTO guix_revisions (git_repository_id, commit) + VALUES ($1, $2) RETURNING id") - (match (exec-query conn insert) + (match (exec-query conn insert (list git-repository-id commit)) (((id)) id))) (define (guix-commit-exists? conn commit) |