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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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