summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 07:14:08 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 07:14:08 +0000
commit8fa53ce43dff48a3e282460c9f9f40dbdfee6e12 (patch)
tree79085e9b8d51824f3bee649681445e1d421d5556 /lib/tasks
parent11f20576e9d236fb0ed2f6882364b10589c37292 (diff)
parent5e7e814e813da0ab9dcadd0c223a3aff6e89dfdd (diff)
downloadgitlab-ce-8fa53ce43dff48a3e282460c9f9f40dbdfee6e12.tar.gz
Merge branch 'check_orphaned_users_groups' into 'master'
Check Orphaned Users Groups
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/check.rake14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index c2e6cd1be78..64ff7330d77 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -17,6 +17,7 @@ namespace :gitlab do
check_database_config_exists
check_database_is_not_sqlite
check_migrations_are_up
+ check_orphaned_users_groups
check_gitlab_config_exists
check_gitlab_config_not_outdated
check_log_writable
@@ -181,6 +182,19 @@ namespace :gitlab do
end
end
+ def check_orphaned_users_groups
+ print "Database contains orphaned UsersGroups? ... "
+ if UsersGroup.where("user_id not in (select id from users)").count > 0
+ 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
+ puts "no".green
+ end
+ end
+
def check_satellites_exist
print "Projects have satellites? ... "