mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 15:54:48 -05:00
FIX: Reset flair group if user is removed from group (#17862)
The flair used to stay set even if the user was removed from the group.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ResetFlairGroupIdIfNotGroupMember < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
execute <<~SQL
|
||||
UPDATE users
|
||||
SET flair_group_id = NULL
|
||||
WHERE flair_group_id IS NOT NULL AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM group_users
|
||||
WHERE group_users.user_id = users.id
|
||||
AND group_users.group_id = users.flair_group_id
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user