views:

842

answers:

3

Hi all, 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!

+2  A: 

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.

Tim Sullivan
+2  A: 

Firstly let me start off by saying that heroku is awesome. I've had a great experience deploying my application and integrating with their other services such as websolr.

With that said, your questions:

Getting at your data

If you want to be able to get to your data you can use taps to pull your remote database down locally. This can be useful for debugging.

Performance monitoring

Use new relic RPM. This comes as part of heroku, you can enable it from the add-ons menu.

Add-hoc database queries

You could write a controller which allows you to execute arbitrary sql and view the results, but this isn't something I'd recommend. As suggest admin_data is a good solution for managing your data, but if you want to do anything more complicated you'll have to resort to writing the code yourself.

jonnii
Hi jonnii, thank you for your answer. I tried taps but it's good only to copy locally the db to run some queries not to add data to the production database (except the first initial restore).admin_data can be good (would be great if it allowed the execution of SQL code :)) but I cannot add rows (think about data to add in a configuration table)...I have to try how I feel with ActiveRecord::Base.connection.execute "some sql" (as Sleepycat said).
zetarun
+3  A: 

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.

Mike Williamson
Hi sleepycat, the problem of taps is that is good only to copy locally the db to run some queries not to add data to the production database. Can you explain better the problem you had with taps?The sql execution of Heroku can be a good - although uncomfortable - solution (only for select and insert, not alter or drop :)).what you say about the bundle is really sad: not possible that Heroku offer a "corrupted" backup service like that...it would be nice to hear some other opinions (perhaps positive:)) on this.Definitely: are you using Amazon RDS with Heroku or you are well with PostGres? :)
zetarun
Taps is apparently the ONLY way to get a large amount of data into Heroku. My problem with it is that it seems to have changed (over a few push/pull operations) from decimal(11,0) (as specified in the migration) to Numeric(11,0) to integer, to int(11) with corrupt data (in my dev db). I had hoped that clean up the mess by creating a new app with all the data in my bundle, but bundles:animate creates a new app but doesn't load any data or code! Meaning I am back to using Taps again which caused the problem to begin with. I still like Heroku a lot, but they really need to work on this.
Mike Williamson