Rails 4 and Postgres Hstore

by Zach Briggs

Rails 4 now supports PostgreSQL's hstore by default, but PostgreSQL does not seem to support PostgreSQL's hstore by default. Whenever I attempted to run a migration that added t.hstore I would get a stack trace that looked a little like this:

rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR: type "hstore" does not exist

I found the magic incantation to stop the angry stack traces here.

Oh, and I feel obligated to remind the world that PostgreSQL is fundamentally a damn good relational database, a fact that I was reminded of the hard way when I over-relied on its JSON storage last year. If your data is fundamentally not relational then maybe consider not using a RDMS. Mongo, for example, is pretty awesome when your data still fits on a single machine.