Skip to content

Commit

Permalink
Make database.yml actually use all the db engines on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mbajur committed Dec 18, 2024
1 parent 757914a commit df4760b
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
<%
db_adapter = ENV.fetch('DB', 'sqlite3')
db_host = ENV.fetch('DB_HOST', ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost'))
db_port = ENV['DB_1_PORT_5432_TCP_PORT'] || ENV['DB_PORT'] ||
{'postgresql' => 5432, 'mysql2' => 3306}[db_adapter]
require 'etc'
db_pool_size = ENV['DB_POOL'] || (
# Web: max workers * max threads
ENV.fetch('WEB_CONCURRENCY', 3).to_i * ENV.fetch('MAX_THREADS', 5).to_i +
# ActiveJob Async max thread pool size
Etc.nprocessors
)
%>

defaults: &defaults
host: <%= db_host %>
port: <%= db_port %>
adapter: <%= db_adapter %>
min_messages: WARNING
pool: <%= db_pool_size %>
username: <%= ENV.fetch('DB_USERNAME', 'inner_performance').inspect %>
password: <%= ENV.fetch('DB_PASSWORD', 'inner_performance').inspect %>

development:
<<: *default
database: storage/development.sqlite3
<<: *defaults
database: <%= db_adapter == 'sqlite3' ? ENV.fetch('DATABASE_FILE', 'db/development.sqlite3') : 'inner_performance_dev' %>

# 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:
<<: *default
database: storage/test.sqlite3
<<: *defaults
database: <%= db_adapter == 'sqlite3' ? ENV.fetch('DATABASE_FILE', 'db/test.sqlite3') : 'inner_performance_test' %>

production:
<<: *default
database: storage/production.sqlite3
<<: *defaults
encoding: utf8
min_messages: WARNING
url: <%= ENV['DATABASE_URL'].inspect if ENV['DATABASE_URL'] %>
database: <%= (db_adapter == 'sqlite3' ? 'db/production.sqlite3' : 'inner_performance_production') unless ENV['DATABASE_URL'] %>

0 comments on commit df4760b

Please sign in to comment.