Commit 5e7e814e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Drop UsersGroup orphans using `rails runner`

parent 4aa3ce75
...@@ -186,6 +186,10 @@ namespace :gitlab do ...@@ -186,6 +186,10 @@ namespace :gitlab do
print "Database contains orphaned UsersGroups? ... " print "Database contains orphaned UsersGroups? ... "
if UsersGroup.where("user_id not in (select id from users)").count > 0 if UsersGroup.where("user_id not in (select id from users)").count > 0
puts "yes".red puts "yes".red
try_fixing_it(
"You can delete the orphaned records using something along the lines of:",
sudo_gitlab("bundle exec rails runner -e production 'UsersGroup.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'")
)
else else
puts "no".green puts "no".green
end 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