diff options
author | Christopher Baines <mail@cbaines.net> | 2022-06-17 12:54:43 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2022-06-17 12:54:43 +0100 |
commit | d19eb07138c5820f4c2fa1a71b7fb499acf39e4d (patch) | |
tree | 6e7bf4a47f01e512f827ff6b12481ac8bee5df18 /sqitch/deploy | |
parent | 3b5950024b06ce0d01ece4d15fa4f8cec271b034 (diff) | |
download | data-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/deploy')
-rw-r--r-- | sqitch/deploy/fix_git_commits_duplicates.sql | 18 |
1 files changed, 18 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; |