Commit 6ea4d333 authored by Stan Hu's avatar Stan Hu

Fix deletion of issue assignees for MySQL

MySQL builds on EE were failing due to MySQL not liking the complex
subqueries. Simplify the deletion to use a subquery that works.
parent 39baadbd
......@@ -37,10 +37,15 @@ module Members
else
project = member.source
IssueAssignee.delete_all(
user_id: member.user_id,
issue_id: project.issues.opened.assigned_to(member.user).select(:id)
)
# SELECT 1 FROM issues WHERE issues.id = issue_assignees.issue_id AND issues.project_id = X
issues = Issue.unscoped.select(1).
where('issues.id = issue_assignees.issue_id').
where(project_id: project.id)
# DELETE FROM issue_assignees WHERE user_id = X AND EXISTS (...)
IssueAssignee.unscoped.
where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues).
delete_all
project.merge_requests.opened.assigned_to(member.user).update_all(assignee_id: nil)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment