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-07-09 12:09:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-09 12:09:53 +0300
commit1613500bf7400f5692a55fd65235a4a10fc40a7d (patch)
tree967ae692bf524c89abdde048d8f74361642293c7 /lib/gitlab/database.rb
parent97576e3dfdc15b26c0a7832608397edd69167351 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index 965ce2bcee9..a269b8d0366 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -72,8 +72,19 @@ module Gitlab
Gitlab::Application.config.database_configuration[Rails.env].include?(database_name.to_s)
end
+ def self.main_database?(name)
+ # The database is `main` if it is a first entry in `database.yml`
+ # Rails internally names them `primary` to avoid confusion
+ # with broad `primary` usage we use `main` instead
+ #
+ # TODO: The explicit `== 'main'` is needed in a transition period till
+ # the `database.yml` is not migrated into `main:` syntax
+ # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65243
+ ActiveRecord::Base.configurations.primary?(name.to_s) || name.to_s == 'main'
+ end
+
def self.ci_database?(name)
- name == CI_DATABASE_NAME
+ name.to_s == CI_DATABASE_NAME
end
def self.username