From d19eb07138c5820f4c2fa1a71b7fb499acf39e4d Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 17 Jun 2022 12:54:43 +0100 Subject: Add an index on git_commits And also remove the duplicates that have crept in. --- sqitch/deploy/fix_git_commits_duplicates.sql | 18 ++++++++++++++++++ sqitch/revert/fix_git_commits_duplicates.sql | 7 +++++++ sqitch/sqitch.plan | 1 + sqitch/verify/fix_git_commits_duplicates.sql | 7 +++++++ 4 files changed, 33 insertions(+) create mode 100644 sqitch/deploy/fix_git_commits_duplicates.sql create mode 100644 sqitch/revert/fix_git_commits_duplicates.sql create mode 100644 sqitch/verify/fix_git_commits_duplicates.sql (limited to 'sqitch') diff --git a/sqitch/deploy/fix_git_commits_duplicates.sql b/sqitch/deploy/fix_git_commits_duplicates.sql new file mode 100644 index 0000000..daf1213 --- /dev/null +++ b/sqitch/deploy/fix_git_commits_duplicates.sql @@ -0,0 +1,18 @@ +-- Deploy guix-data-service:fix_git_commits_duplicates to pg + +BEGIN; + +DELETE FROM git_commits WHERE id IN ( + SELECT DISTINCT b.id + FROM git_commits AS a + INNER JOIN git_commits AS b + ON a.commit = b.commit AND + a.git_branch_id = b.git_branch_id AND + a.datetime = b.datetime AND + a.id != b.id + WHERE a.id < b.id +); + +CREATE UNIQUE INDEX git_commits_unique_idx ON git_commits (git_branch_id, commit, datetime); + +COMMIT; diff --git a/sqitch/revert/fix_git_commits_duplicates.sql b/sqitch/revert/fix_git_commits_duplicates.sql new file mode 100644 index 0000000..d80d9ef --- /dev/null +++ b/sqitch/revert/fix_git_commits_duplicates.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:fix_git_commits_duplicates from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index f71fcbe..6c6e2f1 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -86,3 +86,4 @@ package_derivations_not_null_hash_index 2021-07-11T14:19:32Z Christopher Baines git_branch_id 2022-05-23T18:11:14Z Chris # Add git_branch.id partition_package_derivations_by_guix_revision_range 2022-05-23T18:20:37Z Chris # Partition package_derivations_by_guix_revision_range package_range_index 2022-06-17T10:39:31Z Chris # Add index on package_derivations_by_guix_revision_range.package_name +fix_git_commits_duplicates 2022-06-17T10:39:50Z Chris # Fix git_commits duplicates diff --git a/sqitch/verify/fix_git_commits_duplicates.sql b/sqitch/verify/fix_git_commits_duplicates.sql new file mode 100644 index 0000000..b8fbf2c --- /dev/null +++ b/sqitch/verify/fix_git_commits_duplicates.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:fix_git_commits_duplicates on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; -- cgit v1.2.3