Switch to storing Git repositories in a table

Rather than just storing the URL in the guix_revisions and
load_new_guix_revision_jobs tables. This will help when storing more
information like tags and branches in the future.
This commit is contained in:
Christopher Baines 2019-05-05 13:35:48 +01:00
parent 051962b54d
commit ce4c3c6ed3
12 changed files with 246 additions and 77 deletions

View file

@ -25,21 +25,22 @@
id)
(() #f)))
(define (insert-guix-revision conn url commit store_path)
(define (insert-guix-revision conn git-repository-id commit store_path)
(define insert
(string-append "INSERT INTO guix_revisions "
"(url, commit, store_path) VALUES "
"('" url "', '"
"(git_repository_id, commit, store_path) VALUES "
"(" git-repository-id ", '"
commit "', '"
store_path "') "
"RETURNING id;"))
(map car (exec-query conn insert)))
(define (guix-revision-exists? conn url commit)
(define (guix-revision-exists? conn git-repository-id commit)
(define query
(string-append "SELECT EXISTS("
"SELECT 1 FROM guix_revisions WHERE url = '" url "' "
"SELECT 1 FROM guix_revisions WHERE "
"git_repository_id = '" git-repository-id "' "
"AND commit = '" commit "')"
";"))