Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Production entry for rails database.yml file on Heroku

Just looking at my database.yml file for my Rails 4 app and noticed there isn't any setting for the production database - only the test and development ones.

I don't actually have any issues but wanted to avoid other potential issues by posting this question.

Locally I use a PG database and I host my app on Heroku using a PG db too.

Should I have some settings in the yml for the production database file as I'm really not sure?

like image 350
tommyd456 Avatar asked Nov 07 '13 16:11

tommyd456


3 Answers

Whatever you place in database.yml will be overwritten by Heroku during production deployment, as it uses its own application configuration to effectively write a new one.

https://devcenter.heroku.com/articles/ruby-support#build-behavior

Unless you need to deploy the database.yml to other environments, you can include it in gitignore

like image 122
David Aldridge Avatar answered Nov 14 '22 04:11

David Aldridge


The above answers are no longer valid for Rails 4.x on Heroku. Heroku no longer overwrites your database.yml. You need the following entry in your config/database.yml file:

production:
   url: <%= ENV['DATABASE_URL'] %>
like image 27
Dr. Polar Humenn Avatar answered Nov 14 '22 03:11

Dr. Polar Humenn


If you host your application on Heroku and use a Heroku Postgres DB you don't need a production entry in your database.yml.

Heroku will replace your database.yml entirely with one that uses the DATABASE_URL from heroku:config.

So no, you don't need a production entry in your database.yml for Heroku-hosted apps.

like image 25
Peter Goldstein Avatar answered Nov 14 '22 02:11

Peter Goldstein