Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku App is Reading database.yml File

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?

like image 564
Jonathan Fischoff Avatar asked Dec 17 '22 15:12

Jonathan Fischoff


2 Answers

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.

like image 63
John Beynon Avatar answered Jan 02 '23 11:01

John Beynon


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.

like image 31
p4sh4 Avatar answered Jan 02 '23 10:01

p4sh4