diff options
author | Christopher Baines <mail@cbaines.net> | 2020-03-28 19:59:35 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-03-28 19:59:35 +0000 |
commit | b30904e1afe426e7e38c8a43176efbfc656ab7e6 (patch) | |
tree | a8a47eb5bc978c25f0104f7d2b1220364be95b20 | |
parent | f980b6c2acd4388627b5abb30bdf98fcbb18fb7f (diff) | |
download | data-service-b30904e1afe426e7e38c8a43176efbfc656ab7e6.tar data-service-b30904e1afe426e7e38c8a43176efbfc656ab7e6.tar.gz |
Make jobs unique by commit
Given that a commit, regardless of what repository it comes from should
contain the same exactly the same data, just track jobs by commit.
4 files changed, 46 insertions, 0 deletions
diff --git a/sqitch/deploy/load_new_guix_revision_jobs_make_commits_unique.sql b/sqitch/deploy/load_new_guix_revision_jobs_make_commits_unique.sql new file mode 100644 index 0000000..52ef2d3 --- /dev/null +++ b/sqitch/deploy/load_new_guix_revision_jobs_make_commits_unique.sql @@ -0,0 +1,31 @@ +-- Deploy guix-data-service:load_new_guix_revision_jobs_make_commits_unique to pg + +BEGIN; + +DROP INDEX load_new_guix_revision_jobs_commit_git_repository_id_idx; + +DELETE FROM load_new_guix_revision_job_events +WHERE job_id NOT IN ( + SELECT DISTINCT ON (commit) id + FROM load_new_guix_revision_jobs + ORDER BY commit, succeeded_at ASC NULLS LAST, created_at ASC +) + +DELETE FROM load_new_guix_revision_job_logs +WHERE job_id NOT IN ( + SELECT DISTINCT ON (commit) id + FROM load_new_guix_revision_jobs + ORDER BY commit, succeeded_at ASC NULLS LAST, created_at ASC +); + +DELETE FROM load_new_guix_revision_jobs +WHERE id NOT IN ( + SELECT DISTINCT ON (commit) id + FROM load_new_guix_revision_jobs + ORDER BY commit, succeeded_at ASC NULLS LAST, created_at ASC +); + +CREATE UNIQUE INDEX load_new_guix_revision_jobs_commit_idx + ON load_new_guix_revision_jobs (commit); + +COMMIT; diff --git a/sqitch/revert/load_new_guix_revision_jobs_make_commits_unique.sql b/sqitch/revert/load_new_guix_revision_jobs_make_commits_unique.sql new file mode 100644 index 0000000..57db0bb --- /dev/null +++ b/sqitch/revert/load_new_guix_revision_jobs_make_commits_unique.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:load_new_guix_revision_jobs_make_commits_unique from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index e0c55c7..a92062c 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -55,3 +55,4 @@ make_some_constraints_deferrable 2020-02-16T10:54:22Z Christopher Baines <mail@c guix_revision_system_test_derivations_add_system 2020-03-19T21:30:33Z Christopher Baines <mail@cbaines.net> # Add a system column to the guix_revision_system_test_derivations table drop_package_versions_by_guix_revision_range 2020-03-24T20:40:38Z Christopher Baines <mail@cbaines.net> # Drop package_versions_by_guix_revision_range create_narinfo_fetch_records_index 2020-03-25T19:07:28Z Christopher Baines <mail@cbaines.net> # Create an index on narinfo_fetch_records +load_new_guix_revision_jobs_make_commits_unique 2020-03-27T21:38:42Z Christopher Baines <mail@cbaines.net> # Make load_new_guix_revision_jobs commits unique diff --git a/sqitch/verify/load_new_guix_revision_jobs_make_commits_unique.sql b/sqitch/verify/load_new_guix_revision_jobs_make_commits_unique.sql new file mode 100644 index 0000000..88be8f0 --- /dev/null +++ b/sqitch/verify/load_new_guix_revision_jobs_make_commits_unique.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:load_new_guix_revision_jobs_make_commits_unique on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; |