discourse/config/database.yml
Jarek Radosz 2e4056d185
DEV: Improve multisite db scripts in dev (#17337)
## Without multisite.yml config

No change. `bin/rails db:create` / `db:migrate` / `db:drop` should work the same.

## With multisite.yml config

### db:create

`bin/rails db:create` creates development, test, and all databases from the multisite config

`RAILS_DB=[site] bin/rails db:create` creates the database for the specified site from the multisite config

### db:migrate

`bin/rails db:migrate` migrates the development database and all databases from the multisite config

`RAILS_ENV=test bin/rails db:migrate` migrates the test database and `discourse_test_multisite`

`RAILS_DB=[site] bin/rails db:migrate` migrates the database for the specified site from the multisite config

### db:drop

`bin/rails db:drop` drops development, test, and all databases from the multisite config

`RAILS_DB=[site] bin/rails db:create` drops the database for the specified site from the multisite config
2022-07-06 10:39:03 +02:00

62 lines
2.1 KiB
YAML

development:
prepared_statements: false
adapter: postgresql
database: <%= ENV['DISCOURSE_DEV_DB'] || 'discourse_development' %>
min_messages: warning
pool: 5
timeout: 5000
checkout_timeout: <%= ENV['CHECKOUT_TIMEOUT'] || 5 %>
advisory_locks: false # Disable until https://github.com/rails/rails/issues/40029 has been resolved.
host_names:
### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings.
### If you change this setting you will need to
### - restart sidekiq if you change this setting
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "<%= ENV['DISCOURSE_HOSTNAME'] || '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".
# Do not set this db to the same as development or production.
<%
test_db = ENV["RAILS_TEST_DB"]
if !test_db.present?
test_db = "discourse_test"
if num = ENV["TEST_ENV_NUMBER"]
num = num.presence || "1"
test_db += "_#{num}"
end
end
%>
test:
prepared_statements: false
adapter: postgresql
database: <%= test_db %>
min_messages: warning
pool: 5
timeout: 5000
advisory_locks: false # Disable until https://github.com/rails/rails/issues/40029 has been resolved.
host_names:
- test.localhost
# profile db is used for benchmarking using the script/bench.rb script
profile:
prepared_statements: false
adapter: postgresql
database: discourse_profile
min_messages: warning
pool: 5
timeout: 5000
host_names:
- "localhost"
# You may be surprised production is not here, it is sourced from application.rb using a monkey patch
# This is done for 2 reasons
#
# 1. we need to support blank settings correctly and rendering nothing in yaml/erb is a PITA
# 2. why go from object -> yaml -> object, pointless