Commit 5e7e814e813da0ab9dcadd0c223a3aff6e89dfdd

Authored by Jacob Vosmaer
1 parent 4aa3ce75

Drop UsersGroup orphans using `rails runner`

Showing 1 changed file with 4 additions and 0 deletions   Show diff stats
lib/tasks/gitlab/check.rake
... ... @@ -186,6 +186,10 @@ namespace :gitlab do
186 186 print "Database contains orphaned UsersGroups? ... "
187 187 if UsersGroup.where("user_id not in (select id from users)").count > 0
188 188 puts "yes".red
  189 + try_fixing_it(
  190 + "You can delete the orphaned records using something along the lines of:",
  191 + sudo_gitlab("bundle exec rails runner -e production 'UsersGroup.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'")
  192 + )
189 193 else
190 194 puts "no".green
191 195 end
... ...