aboutsummaryrefslogtreecommitdiff
path: root/sqitch/deploy/fix_null_values_in_git_branches.sql
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-09-29 17:10:04 +0100
committerChristopher Baines <mail@cbaines.net>2019-09-29 17:10:04 +0100
commitb90e6289ac4c370e746170a03eb1d1c696103abf (patch)
tree0c1cca5d430c5b7fff9163c9e06e1010a7180faf /sqitch/deploy/fix_null_values_in_git_branches.sql
parentbd47a03c220bdd9ad66088075f66b61d291aeaa8 (diff)
downloaddata-service-b90e6289ac4c370e746170a03eb1d1c696103abf.tar
data-service-b90e6289ac4c370e746170a03eb1d1c696103abf.tar.gz
Fix the 'NULL' values in git_branches for the commits
The git_branches table had 'NULL' values for some commits where the branch was deleted, importantly this was the string 'NULL', not an actual NULL value. This commit fixes that, migrating the existing values to be '', and changing the relevant code. The primary key is also extended to include the datetime field, as this is important to allow a branch to be deleted twice.
Diffstat (limited to 'sqitch/deploy/fix_null_values_in_git_branches.sql')
-rw-r--r--sqitch/deploy/fix_null_values_in_git_branches.sql11
1 files changed, 11 insertions, 0 deletions
diff --git a/sqitch/deploy/fix_null_values_in_git_branches.sql b/sqitch/deploy/fix_null_values_in_git_branches.sql
new file mode 100644
index 0000000..468d041
--- /dev/null
+++ b/sqitch/deploy/fix_null_values_in_git_branches.sql
@@ -0,0 +1,11 @@
+-- Deploy guix-data-service:fix_null_values_in_git_branches to pg
+
+BEGIN;
+
+ALTER TABLE git_branches DROP CONSTRAINT git_branches_pkey;
+
+UPDATE git_branches SET commit = '' WHERE commit = 'NULL';
+
+ALTER TABLE git_branches ADD PRIMARY KEY (name, commit, git_repository_id, datetime);
+
+COMMIT;