From what I can gather, Heroku is supposed to generate a database.yml file automatically, and ignore the local one. However, I am seeing an error where that is not true, and my changes to the local database.yml are affecting the Heroku app. This is problematic because I have no idea how I should setup production portion of the file so Heroku can find the right database.
For instance with the following
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
followed by the db:migration
$:~/Apps/DancingCupid/DancingCupid$ heroku rake --trace db:migrate
spits out
rake aborted!
unable to open database file
/app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.5/lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `initialize'
...
I can get different errors depending on what type of database I sent for production.
Besides deleting the app and making a new one, is there a way to fix this problem?
Heroku definitely rewrite your database.yml on push so it doesn't matter what is in there in source control.
To confirm this do heroku run bash
which will connect you to a bash session in your app then look do a cat config\database.yml
and you will see how they have rewritten it.
The other answers are NOT TRUE anymore as of Rails 4.1.
config/database.yml won’t be overwritten anymore when a Rails 4.1.0 RC1 app is detected. Instead, it will be merged with DATABASE_URL so additional options like pool size can be set in config/database.yml.
To double-check the contents of your database.yml on the Heroku server, you can run remote bash via heroku run bash
and then cat config/database.yml
to see its contents on the server and compare with your local one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With