Avoid erroring when processing emails again
These changes allow processing emails again, and just creating job and branch entries where data is missing.
This commit is contained in:
parent
712dd377a1
commit
9e80bda4f9
7 changed files with 84 additions and 5 deletions
|
|
@ -630,12 +630,15 @@ WHERE job_id = $1"
|
||||||
"
|
"
|
||||||
INSERT INTO load_new_guix_revision_jobs (git_repository_id, commit, source)
|
INSERT INTO load_new_guix_revision_jobs (git_repository_id, commit, source)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3)
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
RETURNING id;")
|
RETURNING id;")
|
||||||
|
|
||||||
(first
|
(match (exec-query conn
|
||||||
(exec-query conn
|
query
|
||||||
query
|
(list git-repository-id commit source))
|
||||||
(list git-repository-id commit source))))
|
((result)
|
||||||
|
result)
|
||||||
|
(() #f)))
|
||||||
|
|
||||||
(define (select-job-for-commit conn commit)
|
(define (select-job-for-commit conn commit)
|
||||||
(let ((result
|
(let ((result
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
-- Deploy guix-data-service:remove_duplicate_load_new_guix_revision_jobs to pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
DELETE FROM load_new_guix_revision_job_events WHERE job_id NOT IN (
|
||||||
|
SELECT MIN(id) FROM load_new_guix_revision_jobs
|
||||||
|
GROUP BY commit, git_repository_id
|
||||||
|
);
|
||||||
|
|
||||||
|
DELETE FROM load_new_guix_revision_job_logs WHERE job_id NOT IN (
|
||||||
|
SELECT MIN(id) FROM load_new_guix_revision_jobs
|
||||||
|
GROUP BY commit, git_repository_id
|
||||||
|
);
|
||||||
|
|
||||||
|
DELETE FROM load_new_guix_revision_jobs WHERE id NOT IN (
|
||||||
|
SELECT MIN(id) FROM load_new_guix_revision_jobs
|
||||||
|
GROUP BY commit, git_repository_id
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX ON load_new_guix_revision_jobs (
|
||||||
|
commit,
|
||||||
|
git_repository_id
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Revert guix-data-service:remove_duplicate_load_new_guix_revision_jobs from pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- XXX Add DDLs here.
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -17,3 +17,4 @@ load_new_guix_revision_job_logs 2019-06-21T14:33:09Z chris <chris@phact> # Add l
|
||||||
change_load_new_guix_revision_job_logs_contents_to_be_nullable 2019-07-07T20:10:54Z Christopher Baines <mail@cbaines.net> # Change the contents field in the load_new_guix_revision_job_logs table\nto be nullable.\n\nwith '#' will # be ignored, and an empty message aborts the add. #\nChange to add: # #\nchange_load_new_guix_revision_job_logs_contents_to_be_nullable #\nsqitch/deploy/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql\nsqitch/revert/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql\nsqitch/verify/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql
|
change_load_new_guix_revision_job_logs_contents_to_be_nullable 2019-07-07T20:10:54Z Christopher Baines <mail@cbaines.net> # Change the contents field in the load_new_guix_revision_job_logs table\nto be nullable.\n\nwith '#' will # be ignored, and an empty message aborts the add. #\nChange to add: # #\nchange_load_new_guix_revision_job_logs_contents_to_be_nullable #\nsqitch/deploy/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql\nsqitch/revert/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql\nsqitch/verify/change_load_new_guix_revision_job_logs_contents_to_be_nullable.sql
|
||||||
fix_duplicated_licenses 2019-07-30T05:48:17Z Christopher Baines <mail@cbaines.net> # Fix duplicated licenses, and add constraints
|
fix_duplicated_licenses 2019-07-30T05:48:17Z Christopher Baines <mail@cbaines.net> # Fix duplicated licenses, and add constraints
|
||||||
change_git_branches_primary_key 2019-08-05T18:57:41Z Christopher Baines <mail@cbaines.net> # Change the git_branches primary key to include the git_repository_id,\nas this will allow having the same branch in different repositories.
|
change_git_branches_primary_key 2019-08-05T18:57:41Z Christopher Baines <mail@cbaines.net> # Change the git_branches primary key to include the git_repository_id,\nas this will allow having the same branch in different repositories.
|
||||||
|
remove_duplicate_load_new_guix_revision_jobs 2019-08-05T19:06:36Z Christopher Baines <mail@cbaines.net> # Remove duplicate load_new_guix_revision_jobs
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Verify guix-data-service:remove_duplicate_load_new_guix_revision_jobs on pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- XXX Add verifications here.
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
|
|
@ -82,7 +82,24 @@
|
||||||
((id)
|
((id)
|
||||||
(process-load-new-guix-revision-job id))))))
|
(process-load-new-guix-revision-job id))))))
|
||||||
|
|
||||||
(exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE")))
|
(exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE")
|
||||||
|
|
||||||
|
(test-assert "test duplicate job handling"
|
||||||
|
(with-postgresql-transaction
|
||||||
|
conn
|
||||||
|
(lambda (conn)
|
||||||
|
(enqueue-load-new-guix-revision-job
|
||||||
|
conn
|
||||||
|
(git-repository-url->git-repository-id conn "test-url")
|
||||||
|
"test-commit"
|
||||||
|
"test-source")
|
||||||
|
(enqueue-load-new-guix-revision-job
|
||||||
|
conn
|
||||||
|
(git-repository-url->git-repository-id conn "test-url")
|
||||||
|
"test-commit"
|
||||||
|
"test-source")
|
||||||
|
#t)
|
||||||
|
#:always-rollback? #t))))
|
||||||
|
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,25 @@
|
||||||
id
|
id
|
||||||
(current-date)))
|
(current-date)))
|
||||||
#t)
|
#t)
|
||||||
|
#:always-rollback? #t))
|
||||||
|
|
||||||
|
(test-assert "insert-git-branch-entry works twice"
|
||||||
|
(with-postgresql-transaction
|
||||||
|
conn
|
||||||
|
(lambda (conn)
|
||||||
|
(let* ((url "test-url")
|
||||||
|
(id (git-repository-url->git-repository-id conn url)))
|
||||||
|
(insert-git-branch-entry conn
|
||||||
|
"master"
|
||||||
|
"test-commit"
|
||||||
|
id
|
||||||
|
(current-date))
|
||||||
|
(insert-git-branch-entry conn
|
||||||
|
"master"
|
||||||
|
"test-commit"
|
||||||
|
id
|
||||||
|
(current-date)))
|
||||||
|
#t)
|
||||||
#:always-rollback? #t))))
|
#:always-rollback? #t))))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue