Module: Gitlab::Patch::DatabaseConfig

Extended by:
ActiveSupport::Concern
Defined in:
lib/gitlab/patch/database_config.rb

Constant Summary collapse

CommandExecutionError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#database_configurationObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gitlab/patch/database_config.rb', line 14

def database_configuration
  super.to_h do |env, configs|
    parsed_config = parse_extra_config(configs)

    if Gitlab.ee?
      ee_databases = %w[embedding geo]

      ee_databases.each do |ee_db_name|
        next unless parsed_config.key?(ee_db_name)

        migrations_paths = Array(parsed_config[ee_db_name]['migrations_paths'])
        migrations_paths << File.join('ee', 'db', ee_db_name, 'migrate') if migrations_paths.empty?
        migrations_paths << File.join('ee', 'db', ee_db_name, 'post_migrate') unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']

        parsed_config[ee_db_name]['migrations_paths'] = migrations_paths.uniq
        parsed_config[ee_db_name]['schema_migrations_path'] = File.join('ee', 'db', ee_db_name, 'schema_migrations') if parsed_config[ee_db_name]['schema_migrations_path'].blank?
      end
    end

    [env, parsed_config]
  end
end