Skip to content

Customizing the database.yml template

Nathan Pierce edited this page Dec 29, 2017 · 2 revisions

This is how the default database.yml template looks like:

<%= fetch :pg_env %>:
  adapter: postgresql
  encoding: <%= pg_encoding %>
  database: <%= pg_database %>
  pool: <%= pg_pool %>
  username: <%= pg_user %>
  password: '<%= pg_password %>'
  host: <%= pg_host %>
  socket: <%= fetch :pg_socket %>
  port: <%= fetch :pg_port %>
  timeout: <%= fetch :pg_timeout %>

If for any reason you want to edit or tweak this template (not suggested), you can copy it to config/deploy/templates/postgresql.yml.erb with this command:

$ bundle exec rails g capistrano:postgresql:template

After you edit this newly created file in your repo, it will be used as a template for database.yml on the server.

You can configure the template location. For example: set :pg_templates_path, 'config' and the template will be copied to config/postgresql.yml.erb.

Clone this wiki locally