diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/gitlab/patch | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
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] |