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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-23 00:11:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-23 00:11:31 +0300
commit83020ec58ca17261d563b314576b3191e08afba0 (patch)
tree40fb02ec3265a0ddb2c5e3fec6284986dac7484e /lib/gitlab/database.rb
parent88620da25def237534c9156d133be46d4da6310b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index 385ac40cf13..b2e2b013947 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -49,18 +49,23 @@ module Gitlab
# It does not include the default public schema
EXTRA_SCHEMAS = [DYNAMIC_PARTITIONS_SCHEMA, STATIC_PARTITIONS_SCHEMA].freeze
- DATABASES = ActiveRecord::Base
- .connection_handler
- .connection_pools
- .each_with_object({}) do |pool, hash|
- hash[pool.db_config.name.to_sym] = Connection.new(pool.connection_klass)
- end
- .freeze
-
PRIMARY_DATABASE_NAME = ActiveRecord::Base.connection_db_config.name.to_sym
+ def self.database_base_models
+ @database_base_models ||= {
+ main: ::ApplicationRecord,
+ ci: ::Ci::CiDatabaseRecord.connection_class? ? ::Ci::CiDatabaseRecord : nil
+ }.compact.freeze
+ end
+
+ def self.databases
+ @databases ||= database_base_models
+ .transform_values { |connection_class| Connection.new(connection_class) }
+ .freeze
+ end
+
def self.main
- DATABASES[PRIMARY_DATABASE_NAME]
+ databases[PRIMARY_DATABASE_NAME]
end
# We configure the database connection pool size automatically based on the
@@ -99,7 +104,7 @@ module Gitlab
def self.check_postgres_version_and_print_warning
return if Gitlab::Runtime.rails_runner?
- DATABASES.each do |name, connection|
+ databases.each do |name, connection|
next if connection.postgresql_minimum_supported_version?
Kernel.warn ERB.new(Rainbow.new.wrap(<<~EOS).red).result
@@ -111,7 +116,7 @@ module Gitlab
 ███ ███  ██  ██ ██  ██ ██   ████ ██ ██   ████  ██████  
******************************************************************************
- You are using PostgreSQL <%= Gitlab::Database.main.version %> for the #{name} database, but PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>
+ You are using PostgreSQL #{connection.version} for the #{name} database, but PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>
is required for this version of GitLab.
<% if Rails.env.development? || Rails.env.test? %>
If using gitlab-development-kit, please find the relevant steps here: