Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensures score is 0 and not null if no associated reviewable_scores

Joffrey JAFFEUXc66ae1903751
diff --git a/db/migrate/20190327205525_require_reviewable_scores.rb b/db/migrate/20190327205525_require_reviewable_scores.rb
index 85ab95f1267..217661eda10 100644
--- a/db/migrate/20190327205525_require_reviewable_scores.rb
+++ b/db/migrate/20190327205525_require_reviewable_scores.rb
@@ -26,7 +26,7 @@ class RequireReviewableScores < ActiveRecord::Migration[5.2]
execute(<<~SQL)
UPDATE reviewables SET score = (
- SELECT SUM(score)
+ SELECT COALESCE(SUM(score), 0)
FROM reviewable_scores
WHERE reviewable_scores.reviewable_id = reviewables.id
)