aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--guix-data-service/branch-updated-emails.scm2
-rw-r--r--guix-data-service/web/view/html.scm4
-rw-r--r--sqitch/deploy/fix_null_values_in_git_branches.sql11
-rw-r--r--sqitch/revert/fix_null_values_in_git_branches.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/verify/fix_null_values_in_git_branches.sql7
6 files changed, 29 insertions, 3 deletions
diff --git a/guix-data-service/branch-updated-emails.scm b/guix-data-service/branch-updated-emails.scm
index 246ba53..df5771e 100644
--- a/guix-data-service/branch-updated-emails.scm
+++ b/guix-data-service/branch-updated-emails.scm
@@ -50,7 +50,7 @@
branch-name
(if (string=? "0000000000000000000000000000000000000000"
x-git-newrev)
- "NULL"
+ ""
x-git-newrev)
git-repository-id
date)
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index 872d6cc..20a02fc 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -940,7 +940,7 @@
"/branch/" name)))
,name))
(td ,date)
- (td ,@(if (string=? commit "NULL")
+ (td ,@(if (string=? commit "")
'((samp "branch deleted"))
`((a (@ (href ,(string-append
"/revision/" commit)))
@@ -1048,7 +1048,7 @@
(previous-commit previous-revision-exists?))
`(tr
(td ,date)
- (td ,@(if (string=? commit "NULL")
+ (td ,@(if (string=? commit "")
'((samp "branch deleted"))
`((a (@ (href ,(string-append
"/revision/" commit)))
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;
diff --git a/sqitch/revert/fix_null_values_in_git_branches.sql b/sqitch/revert/fix_null_values_in_git_branches.sql
new file mode 100644
index 0000000..e4991fc
--- /dev/null
+++ b/sqitch/revert/fix_null_values_in_git_branches.sql
@@ -0,0 +1,7 @@
+-- Revert guix-data-service:fix_null_values_in_git_branches from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index ff17ebd..859258a 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -22,3 +22,4 @@ lint_warnings 2019-08-18T17:10:12Z Christopher Baines <mail@cbaines.net> # Store
guix_revision_lint_checkers 2019-09-01T12:17:38Z chris <chris@phact> # Associate lint_checkers to guix_revisions
package_versions_by_guix_revision_range 2019-09-26T20:23:15Z Christopher Baines <mail@cbaines.net> # Add package_versions_by_guix_revision_range table
index_on_load_new_guix_revision_job_events_job_id 2019-09-29T10:39:04Z Christopher Baines <mail@cbaines.net> # Add index on load_new_guix_revision_job_events.job_id
+fix_null_values_in_git_branches 2019-09-29T11:06:12Z Christopher Baines <mail@cbaines.net> # Fix the NULL values in git_branches
diff --git a/sqitch/verify/fix_null_values_in_git_branches.sql b/sqitch/verify/fix_null_values_in_git_branches.sql
new file mode 100644
index 0000000..b8176a8
--- /dev/null
+++ b/sqitch/verify/fix_null_values_in_git_branches.sql
@@ -0,0 +1,7 @@
+-- Verify guix-data-service:fix_null_values_in_git_branches on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;