Monday, May 30, 2011

The Ugly Underbelly of the Switch to Amazon RDS on Heroku

If you've decided to make the switch from Heroku's default PostgreSQL database to an Amazon RDS db, you may have come across this helpful article: http://devcenter.heroku.com/articles/amazon_rds

What that article doesn't tell you is:

  1. You'll probably need to add the mysql2 gem to your Gemfile.
  2. The newest version of the mysql2 gem won't work with Rails 3.0.x, so you'll need to do gem 'mysql2', '< 0.3'. The article may not tell you this, but the errors you'll see in the Heroku logs helpfully point this out.
  3. Your DATABASE_URL Heroku config var should start with mysql2:// instead of mysql://.

Also, I find the Amazon console to be easier to use than the command line RDS tools Heroku's article steers you towards. The one pitfall is their IP address suggestion is wrong for adding CIDR/IP access to a security group.

However the taps gem the article recommends worked like a dream--albeit a dream interrupted by a brief nightmare that you don't have the mysql gem installed. Since I'm using OS X, that was as easy as
env ARCHFLAGS="-arch x86_64" gem install mysql.

If a recent survey I received from Heroku asking about my RDS usage is any indication, they may come out with a mysql database service themselves. On that day, I will celebrate, do some case insensitive searches and insert-or-updates, and celebrate some more.