A platform for community discussion. Free, open, simple.
FEATURE: allow setting postgres connection variables via environment
Michael Browndda1cd6a3844
diff --git a/app/models/global_setting.rb b/app/models/global_setting.rbindex 8543ca6ebbe..fba25eccdc7 100644--- a/app/models/global_setting.rb+++ b/app/models/global_setting.rb@@ -154,6 +154,14 @@ class GlobalSettinghash["reaping_frequency"] = connection_reaper_interval if connection_reaper_interval.present?hash["advisory_locks"] = !!self.db_advisory_locks+ db_variables = provider.keys.filter { |k| k.to_s.starts_with? 'db_variables_' }+ if db_variables.length > 0+ hash["variables"] = {}+ db_variables.each do |k|+ hash["variables"][k.slice(('db_variables_'.length)..)] = self.public_send(k)+ end+ end+{ "production" => hash }enddiff --git a/config/database.yml b/config/database.ymlindex 32be4265b88..be92da494de 100644--- a/config/database.yml+++ b/config/database.yml@@ -13,6 +13,9 @@ development:### - restart sidekiq if you change this setting### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`- "localhost"+ variables: <%= ENV.filter { |k,v| k.start_with? 'DISCOURSE_DB_VARIABLES_' }+ .transform_keys { |k| k.slice(('DISCOURSE_DB_VARIABLES_'.length)..).downcase }+ .to_json %># Warning: The database defined as "test" will be erased and# re-generated from your development database when you run "rake".