aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-07-26 17:32:38 -0400
committerGitHub <noreply@github.com>2019-07-26 17:32:38 -0400
commit798723177997a121e787f686bbf4586027fc2375 (patch)
tree776012e43cad6a096ba27fdda7e6ece530287f30 /activerecord/lib
parentefa2299ac3bbf86feacfa337645654f87109e769 (diff)
parent7df0eefacf1b6cbfdad8775ac86c6917f16bf859 (diff)
downloadrails-798723177997a121e787f686bbf4586027fc2375.tar.gz
rails-798723177997a121e787f686bbf4586027fc2375.tar.bz2
rails-798723177997a121e787f686bbf4586027fc2375.zip
Merge pull request #36773 from seejohnrun/db-configuration-separate-env-vars
Allow separate database env variables per-connection
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/database_configurations.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/database_configurations.rb b/activerecord/lib/active_record/database_configurations.rb
index 3e387782f6..fcf13a910c 100644
--- a/activerecord/lib/active_record/database_configurations.rb
+++ b/activerecord/lib/active_record/database_configurations.rb
@@ -181,12 +181,19 @@ module ActiveRecord
end
def environment_url_config(env, spec_name, config)
- url = ENV["DATABASE_URL"]
+ url = environment_value_for(spec_name)
return unless url
ActiveRecord::DatabaseConfigurations::UrlConfig.new(env, spec_name, url, config)
end
+ def environment_value_for(spec_name)
+ spec_env_key = "#{spec_name.upcase}_DATABASE_URL"
+ url = ENV[spec_env_key]
+ url ||= ENV["DATABASE_URL"] if spec_name == "primary"
+ url
+ end
+
def method_missing(method, *args, &blk)
case method
when :fetch