aboutsummaryrefslogtreecommitdiff
path: root/sqitch
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-06-17 12:54:43 +0100
committerChristopher Baines <mail@cbaines.net>2022-06-17 12:54:43 +0100
commitd19eb07138c5820f4c2fa1a71b7fb499acf39e4d (patch)
tree6e7bf4a47f01e512f827ff6b12481ac8bee5df18 /sqitch
parent3b5950024b06ce0d01ece4d15fa4f8cec271b034 (diff)
downloaddata-service-d19eb07138c5820f4c2fa1a71b7fb499acf39e4d.tar
data-service-d19eb07138c5820f4c2fa1a71b7fb499acf39e4d.tar.gz
Add an index on git_commits
And also remove the duplicates that have crept in.
Diffstat (limited to 'sqitch')
-rw-r--r--sqitch/deploy/fix_git_commits_duplicates.sql18
-rw-r--r--sqitch/revert/fix_git_commits_duplicates.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/verify/fix_git_commits_duplicates.sql7
4 files changed, 33 insertions, 0 deletions
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 <chris@felis> # Add git_branch.id
partition_package_derivations_by_guix_revision_range 2022-05-23T18:20:37Z Chris <chris@felis> # Partition package_derivations_by_guix_revision_range
package_range_index 2022-06-17T10:39:31Z Chris <chris@felis> # Add index on package_derivations_by_guix_revision_range.package_name
+fix_git_commits_duplicates 2022-06-17T10:39:50Z Chris <chris@felis> # 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;