Skip to content

Instantly share code, notes, and snippets.

@datt
Last active April 7, 2021 13:31
Show Gist options
  • Save datt/e12fa0da294e7a8f3ac96abee346a098 to your computer and use it in GitHub Desktop.
Save datt/e12fa0da294e7a8f3ac96abee346a098 to your computer and use it in GitHub Desktop.
Rails Database yml examples for postgres sqlite and mysql
# Install the MySQL gem:
# gem install mysql2
default: &default
adapter: mysql2
encoding: utf8mb4
reconnect: false
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
development:
<<: *default
database: app_name_development
test:
<<: *default
database: app_name_test
staging:
<<: *default
database: app_name_staging
production:
<<: *default
database: app_name_production
# Install the pg gem:
# gem install pg
default: &default
adapter: postgresql
encoding: unicode
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: postgres
password:
development:
<<: *default
database: app_name_development
test:
<<: *default
database: app_name_test
staging:
<<: *default
database: app_name_staging
production:
<<: *default
database: app_name_production
# SQLite version 3.x
# gem install sqlite3
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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: db/test.sqlite3
staging:
<<: *default
database: db/staging.sqlite3
production:
<<: *default
database: db/production.sqlite3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment