diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/tasks/gitlab/db.rake | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/db.rake')
-rw-r--r-- | lib/tasks/gitlab/db.rake | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index a3f20f31f64..901e349ea31 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -192,16 +192,42 @@ namespace :gitlab do exit end - indexes = if args[:index_name] - [Gitlab::Database::PostgresIndex.by_identifier(args[:index_name])] - else - Gitlab::Database::Reindexing.candidate_indexes.random_few(2) - end + indexes = Gitlab::Database::Reindexing.candidate_indexes + + if identifier = args[:index_name] + raise ArgumentError, "Index name is not fully qualified with a schema: #{identifier}" unless identifier =~ /^\w+\.\w+$/ + + indexes = indexes.where(identifier: identifier) + + raise "Index not found or not supported: #{args[:index_name]}" if indexes.empty? + end + + ActiveRecord::Base.logger = Logger.new(STDOUT) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false) Gitlab::Database::Reindexing.perform(indexes) rescue => e Gitlab::AppLogger.error(e) raise end + + desc 'Check if there have been user additions to the database' + task active: :environment do + if ActiveRecord::Base.connection.migration_context.needs_migration? + puts "Migrations pending. Database not active" + exit 1 + end + + # A list of projects that GitLab creates automatically on install/upgrade + # gc = Gitlab::CurrentSettings.current_application_settings + seed_projects = [Gitlab::CurrentSettings.current_application_settings.self_monitoring_project] + + if (Project.count - seed_projects.count {|x| !x.nil? }).eql?(0) + puts "No user created projects. Database not active" + exit 1 + end + + puts "Found user created projects. Database active" + exit 0 + end end end |