diff --git a/.env.sample b/.env.sample index c804ae841..9a9397b0e 100644 --- a/.env.sample +++ b/.env.sample @@ -26,23 +26,6 @@ # export UNICORN_USER=danbooru # export UNICORN_GROUP=danbooru -# -# Database -# - -# DATABASE_URL takes precedence over config/database.yml if defined. - -# Put these in .env.production or .env.development to define your dev/prod -# databases. Do not define it in .env or .env.local! It will be taken as your -# test database too, and rails will wipe it if you run the test suite. -# -# If you are connecting to PostgreSQL via socket, omit the hostname (e.g. -# postgresql:///danbooru2) -# export DATABASE_URL="postgresql://localhost/danbooru2" - -# Put these in .env.test to define your test database. -# export DATABASE_URL="postgresql://localhost/danbooru2_test" - # # Rails # diff --git a/.gitignore b/.gitignore index b27813fcd..33c41b774 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .env +.env.production .bundle .yardoc -config/database.yml config/danbooru_local_config.rb config/deploy/*.rb config/application.yml diff --git a/bin/setup b/bin/setup index 33ebd5533..9d3a21ca1 100755 --- a/bin/setup +++ b/bin/setup @@ -14,9 +14,6 @@ FileUtils.chdir APP_ROOT do # Add necessary setup steps to this file. puts "\n== Copying sample files ==" - unless File.exist?('config/database.yml') - FileUtils.cp 'docker/database.yml', 'config/database.yml' - end unless File.exist?('config/danbooru_local_config.rb') FileUtils.cp 'docker/danbooru_local_config.rb', 'config/danbooru_local_config.rb' end diff --git a/config/database.yml b/config/database.yml new file mode 100755 index 000000000..f78819fa7 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,25 @@ +default: &default + adapter: postgresql + timeout: 5000 + +development: + <<: *default + database: danbooru2 + username: danbooru + host: postgres + pool: 5 + +test: + <<: *default + database: danbooru2_test + username: danbooru + host: postgres + pool: 5 + +production: + <<: *default + database: e621 + username: e621 + password: <%= ENV["DB_PASSWORD"] %> + host: <%= ENV["DB_HOST"] %> + pool: <%= Sidekiq.server? ? ENV["DB_WORKER_POOL_SIZE"] : ENV["DB_POOL_SIZE"] %> diff --git a/docker-compose.yml b/docker-compose.yml index 6a743f293..048e08c0c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ version: "3" x-environment: &common-env - DATABASE_URL: postgresql://danbooru:@postgres DANBOORU_HOSTNAME: http://localhost:3000 DANBOORU_REDIS_URL: redis://redis DANBOORU_ELASTICSEARCH_HOST: elastic diff --git a/docker/database.yml b/docker/database.yml deleted file mode 100755 index b3e59c04b..000000000 --- a/docker/database.yml +++ /dev/null @@ -1,25 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) -development: - adapter: postgresql - database: danbooru2 - pool: 5 - timeout: 5000 - url: <%= ENV['DATABASE_URL'] %> - -# 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: - adapter: postgresql - database: danbooru2_test - pool: 5 - timeout: 5000 - url: <%= ENV['DATABASE_URL'] %> - -production: - adapter: postgresql - database: danbooru2 - pool: 5 - timeout: 5000 - url: <%= ENV['DATABASE_URL'] %>