Skip to content

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

FIX: Migration should only update ReviewableUsers where the user is not approved. (#10790)

Roman Rizzi7d5b18b7cfc0
diff --git a/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb b/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
index 07cb662d74e..d26e4acb4cc 100644
--- a/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
+++ b/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
@@ -5,7 +5,8 @@ class ClearApprovedUsersFromTheReviewQueue < ActiveRecord::Migration[6.0]
UPDATE reviewables r
SET status = #{Reviewable.statuses[:approved]}
FROM users u
- WHERE u.approved = true AND r.type = 'ReviewableUser' AND r.status = #{Reviewable.statuses[:pending]}
+ WHERE u.id = r.target_id AND u.approved = true
+ AND r.type = 'ReviewableUser' AND r.status = #{Reviewable.statuses[:pending]}
RETURNING r.id
SQL