config: set default database connection settings.

Set sensible defaults for connecting to the database. By default, we try
to connect to the `danbooru2` database running on localhost as the
`danbooru` user. These are the defaults recommended by the install
guide.

If you need to change the database settings, set DATABASE_URL in
.env.local or on the command line:

   # .env.local
   DATABASE_URL=postgresql://danbooru:password@localhost/danbooru2

   # command line
   $ DATABASE_URL=postgresql://danbooru:password@localhost/danbooru2 bin/rails server

This eliminates the need to copy script/install/database.yml.templ to
config/database.yml during installation and during deployment. This is
so that Danbooru works out of the box without extra configuration. In
particular, this is so that we can run Danbooru in a Docker container
without having to set DATABASE_URL.
This commit is contained in:
evazion
2021-03-23 02:29:45 -05:00
parent 6a84d33409
commit 189adc683f
5 changed files with 39 additions and 48 deletions

39
config/database.yml Normal file
View File

@@ -0,0 +1,39 @@
# Don't edit this file. To override this file, set `DATABASE_URL` in .env.local
# instead. Example:
#
# DATABASE_URL=postgresql://danbooru:password@localhost/danbooru2
#
# https://guides.rubyonrails.org/configuring.html#configuring-a-database
default: &default
adapter: postgresql
username: danbooru
host: localhost
url: <%= ENV["DATABASE_URL"] %>
production:
<<: *default
database: danbooru2
development:
<<: *default
database: danbooru2
test:
<<: *default
database: danbooru2_test
archive_production:
<<: *default
database: archive_production
url: <%= ENV["ARCHIVE_DATABASE_URL"] %>
archive_development:
<<: *default
database: archive_development
url: <%= ENV["ARCHIVE_DATABASE_URL"] %>
archive_test:
<<: *default
database: archive_test
url: <%= ENV["ARCHIVE_DATABASE_URL"] %>