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>2022-03-28 21:07:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-28 21:07:56 +0300
commit1b6c8b34c1301ece8383b4a7950270a757304c0b (patch)
treefcdd5518b2e7b9d2308797e3203eb8a47c813b56 /lib/gitlab/patch
parentb213b675ec1d6fa633497c5f71c195f00b56be6d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/patch')
-rw-r--r--lib/gitlab/patch/database_config.rb (renamed from lib/gitlab/patch/legacy_database_config.rb)41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/gitlab/patch/legacy_database_config.rb b/lib/gitlab/patch/database_config.rb
index 6040f737c75..702e8d404b1 100644
--- a/lib/gitlab/patch/legacy_database_config.rb
+++ b/lib/gitlab/patch/database_config.rb
@@ -28,7 +28,7 @@
module Gitlab
module Patch
- module LegacyDatabaseConfig
+ module DatabaseConfig
extend ActiveSupport::Concern
prepended do
@@ -73,23 +73,34 @@ module Gitlab
@uses_legacy_database_config = false # rubocop:disable Gitlab/ModuleWithInstanceVariables
super.to_h do |env, configs|
- # This check is taken from Rails where the transformation
- # of a flat database.yml is done into `primary:`
- # https://github.com/rails/rails/blob/v6.1.4/activerecord/lib/active_record/database_configurations.rb#L169
- if configs.is_a?(Hash) && !configs.all? { |_, v| v.is_a?(Hash) }
- configs = { "main" => configs }
-
- @uses_legacy_database_config = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # TODO: To be removed in 15.0. See https://gitlab.com/gitlab-org/gitlab/-/issues/338182
+ # This preload is needed to convert legacy `database.yml`
+ # from `production: adapter: postgresql`
+ # into a `production: main: adapter: postgresql`
+ unless Gitlab::Utils.to_boolean(ENV['SKIP_DATABASE_CONFIG_VALIDATION'], default: false)
+ # This check is taken from Rails where the transformation
+ # of a flat database.yml is done into `primary:`
+ # https://github.com/rails/rails/blob/v6.1.4/activerecord/lib/active_record/database_configurations.rb#L169
+ if configs.is_a?(Hash) && !configs.all? { |_, v| v.is_a?(Hash) }
+ configs = { "main" => configs }
+
+ @uses_legacy_database_config = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ end
end
- if Gitlab.ee? && File.exist?(Rails.root.join("config/database_geo.yml"))
- migrations_paths = ["ee/db/geo/migrate"]
- migrations_paths << "ee/db/geo/post_migrate" unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']
+ if Gitlab.ee?
+ if !configs.key?("geo") && File.exist?(Rails.root.join("config/database_geo.yml"))
+ configs["geo"] = Rails.application.config_for(:database_geo).stringify_keys
+ end
+
+ if configs.key?("geo")
+ migrations_paths = Array(configs["geo"]["migrations_paths"])
+ migrations_paths << "ee/db/geo/migrate" if migrations_paths.empty?
+ migrations_paths << "ee/db/geo/post_migrate" unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']
- configs["geo"] =
- Rails.application.config_for(:database_geo)
- .merge(migrations_paths: migrations_paths, schema_migrations_path: "ee/db/geo/schema_migrations")
- .stringify_keys
+ configs["geo"]["migrations_paths"] = migrations_paths.uniq
+ configs["geo"]["schema_migrations_path"] = "ee/db/geo/schema_migrations" if configs["geo"]["schema_migrations_path"].blank?
+ end
end
[env, configs]