diff options
author | Christopher Baines <mail@cbaines.net> | 2019-12-05 14:10:09 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-12-05 15:42:58 +0100 |
commit | 80043e00596da1f872149465d642cb2bf8bceddb (patch) | |
tree | 57fec608f574f83fb244021d2db0ef3761ac4e67 /sqitch | |
parent | 9c71dd3ae38d6ee46fd11385c0670d4876f33972 (diff) | |
download | data-service-80043e00596da1f872149465d642cb2bf8bceddb.tar data-service-80043e00596da1f872149465d642cb2bf8bceddb.tar.gz |
WIP sort out deduplicate builds
Diffstat (limited to 'sqitch')
-rw-r--r-- | sqitch/deploy/sort_out_duplicate_builds.sql | 33 | ||||
-rw-r--r-- | sqitch/revert/sort_out_duplicate_builds.sql | 7 | ||||
-rw-r--r-- | sqitch/sqitch.plan | 1 | ||||
-rw-r--r-- | sqitch/verify/sort_out_duplicate_builds.sql | 7 |
4 files changed, 48 insertions, 0 deletions
diff --git a/sqitch/deploy/sort_out_duplicate_builds.sql b/sqitch/deploy/sort_out_duplicate_builds.sql new file mode 100644 index 0000000..92bd2c5 --- /dev/null +++ b/sqitch/deploy/sort_out_duplicate_builds.sql @@ -0,0 +1,33 @@ +-- Deploy guix-data-service:sort_out_duplicate_builds to pg + +BEGIN; + +DELETE FROM build_status WHERE build_id IN ( + SELECT builds.id + FROM builds + INNER JOIN ( + SELECT derivation_file_name, MIN(id) AS id + FROM builds + GROUP BY build_server_id, derivation_file_name + HAVING COUNT(DISTINCT id) > 1 + ) AS min_ids + ON min_ids.derivation_file_name = builds.derivation_file_name AND + min_ids.id != builds.id +); + +DELETE FROM builds WHERE id IN ( + SELECT builds.id + FROM builds + INNER JOIN ( + SELECT derivation_file_name, MIN(id) AS id + FROM builds + GROUP BY build_server_id, derivation_file_name + HAVING COUNT(DISTINCT id) > 1 + ) AS min_ids + ON min_ids.derivation_file_name = builds.derivation_file_name AND + min_ids.id != builds.id +); + +CREATE UNIQUE INDEX ON builds (build_server_id, derivation_file_name); + +COMMIT; diff --git a/sqitch/revert/sort_out_duplicate_builds.sql b/sqitch/revert/sort_out_duplicate_builds.sql new file mode 100644 index 0000000..153a4ef --- /dev/null +++ b/sqitch/revert/sort_out_duplicate_builds.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:sort_out_duplicate_builds from pg + +BEGIN; + +DROP INDEX builds_build_server_id_derivation_file_name_idx; + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index 9c6389c..45f6921 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -35,3 +35,4 @@ narinfo_fetch_record 2019-12-03T20:53:28Z <chris@phact> # Add a table to descr equivalent_derivations 2019-12-04T16:43:37Z <chris@phact> # Add equivalent_derivations table change_nars_size_to_bigint 2019-12-04T21:24:21Z <chris@phact> # Change nars.size to bigint change_nar_urls_size_to_bigint 2019-12-04T21:49:07Z <chris@phact> # Change nar_urls.size to bigint +sort_out_duplicate_builds 2019-12-05T12:43:53Z <chris@phact> # Sort out duplicate builds diff --git a/sqitch/verify/sort_out_duplicate_builds.sql b/sqitch/verify/sort_out_duplicate_builds.sql new file mode 100644 index 0000000..a63cda4 --- /dev/null +++ b/sqitch/verify/sort_out_duplicate_builds.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:sort_out_duplicate_builds on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; |