Demonstrating how Heroku handles your database

Heroku is an amazing platform for hosting Rack-compilant web applications. Although some people complain about steep pricing, I'm sure that many will feel that the productivity gain is worth it. I'll provide more detail about Heroku and how I/we use it later. This post will simply show how database configuration is done when you work with Heroku. I think this might be a bit vague in the documentation, some people get confused over it. Lets utilize the console:

zero:~/Projects/crantastic $ heroku console
Ruby console for crantastic.heroku.com
>> puts File.read(Rails.configuration.database_configuration_file)
---
production:
  encoding: unicode
  adapter: postgresql
  username: something_random
  port: 5432
  host: somewhere.at.heroku
  database: something_random
  password: something_random

=> nil
>>

Heroku in practice replaces your apps database.yml when you push your site to their servers. Your data will be stored in one of their fancy PostgreSQL servers no matter what you use locally - this means that you don't have to think about database.yml at all (except for development purpses, naturally). Taps makes sure that everything's db agnostic. If you want to push your latest development db to Heroku, simply run heroku db:push. Awesome!

blog comments powered by Disqus