Welcome to mirror list, hosted at ThFree Co, Russian Federation.

orphaned_group_members_check.rb « app « system_check « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2b46d36fe517440a77802ac9bc9ed2f13db498db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module SystemCheck
  module App
    class OrphanedGroupMembersCheck < SystemCheck::BaseCheck
      set_name 'Database contains orphaned GroupMembers?'
      set_check_pass 'no'
      set_check_fail 'yes'

      def check?
        !GroupMember.where('user_id not in (select id from users)').exists?
      end

      def show_error
        try_fixing_it(
          'You can delete the orphaned records using something along the lines of:',
          sudo_gitlab("bundle exec rails runner -e production 'GroupMember.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'")
        )
      end
    end
  end
end