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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 11:14:08 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 11:14:08 +0400
commit8fa53ce43dff48a3e282460c9f9f40dbdfee6e12 (patch)
tree79085e9b8d51824f3bee649681445e1d421d5556 /lib
parent11f20576e9d236fb0ed2f6882364b10589c37292 (diff)
parent5e7e814e813da0ab9dcadd0c223a3aff6e89dfdd (diff)
Merge branch 'check_orphaned_users_groups' into 'master'
Check Orphaned Users Groups
Diffstat (limited to 'lib')
-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? ... "