Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB management for Heroku apps

I'm fairly new to both Rails and Heroku but I'm seriously thinking of using it as a platform to deploy my Ruby/Rails applications.

I want to use all the power of Heroku, so I prefer the "embedded" PostgreSQL managed by Heroku instead of the addon for Amazon RDS for MySQL, but I'm not so confident without the possibility to access my data in a SQL client...

I know that in a well made app you have no need to access DB, but there are some situations (add rows to a config table, see data not mapped in a view, update some columns for debugging issues, performance monitoring, running queries for reporting, etc.) when this can be good...

How do you solve this problem? What's you experience in a real life app powered by Heroku?

Thanks!

like image 524
zetarun Avatar asked Mar 16 '10 18:03

zetarun


2 Answers

I have been using it for a about a year. I love the workflow that it provides but I find not having access to the data is a real bother. Your options for working with database are:

Taps: In theory you create your database however you want locally and use taps to copy both schema and data to Heroku. In practice, most of the time its amazingly great. However I am currently dealing with the cleanup after taps translated some of my columns poorly and corrupted my data.

Heroku console: Totally fine for all the usual ActiveRecord stuff, but closest you can get to the database is ActiveRecord::Base.connection.execute "some sql". When you find yourself wondering about doing alter table commands like that you will know you're in trouble.

They also provide a "bundle" as a method for backing up your app. This lets you download all your code plus a sql dump of the database. The difficulty is that since there is no direct database access there is no way of loading that same sql dump back into the database so you can recover from dataloss, which, to me, is the point of having those dump files to begin with. All you can use the bundle for is to create a new application (heroku bundles:animate), not restore a current app.

I would love to be wrong about any/all of these. This seems like a curious rough spot in the best thought out service that I know of. Database access normally doesn't feel like much to give up when most of what you do is made so easy.

To me database access is like a fire extinguisher. Usually not a big deal, but when it matters, it matters a lot.

like image 81
mikewilliamson Avatar answered Sep 27 '22 18:09

mikewilliamson


I use admin_data to give me some insight as to what is going on. I've successfully used it on Heroku, as well as other hosting providers.

like image 25
Tim Sullivan Avatar answered Sep 27 '22 19:09

Tim Sullivan