diff --git a/db/20180923004309-comment-count-build.sql b/db/20180923004309-comment-count-build.sql new file mode 100644 index 0000000..8c826e2 --- /dev/null +++ b/db/20180923004309-comment-count-build.sql @@ -0,0 +1,10 @@ +-- Build the comments count column + +UPDATE pages +SET commentCount = subquery.commentCount +FROM ( + SELECT COUNT(commentHex) as commentCount + FROM comments + WHERE state = 'approved' + GROUP BY (domain, path) +) as subquery;