FEATURE: allow setting postgres connection variables via environment

This commit is contained in:
Michael Brown 2021-04-14 11:34:28 -04:00 committed by Michael Brown
parent 99dadb2129
commit dda1cd6a38
2 changed files with 11 additions and 0 deletions

View File

@ -154,6 +154,14 @@ class GlobalSetting
hash["reaping_frequency"] = connection_reaper_interval if connection_reaper_interval.present? hash["reaping_frequency"] = connection_reaper_interval if connection_reaper_interval.present?
hash["advisory_locks"] = !!self.db_advisory_locks 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 } { "production" => hash }
end end

View File

@ -13,6 +13,9 @@ development:
### - restart sidekiq if you change this setting ### - restart sidekiq if you change this setting
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake` ### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "localhost" - "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 # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".