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

The reviewable was updated despite the user not being approved because a u.id = r.target_id condition is missing. It only affected user reviewables that were pending when the migration ran. Users were not auto-approved.
This commit is contained in:
Roman Rizzi
2020-10-01 08:49:10 -03:00
committed by GitHub
parent 3de832248e
commit 7d5b18b7cf

View File

@@ -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