Rails/Postgres DB Migration Issue #996
I ran across a new Postgres-related bug today while trying to run a migrate task on a client project. The error message looked like this, and I’d never seen it before:
undefined method `transaction_status' for #<PGconn:0x21fb920>
A little research uncovered the fact that this behaviour was actually issue #996 in the Rails Lighthouse (a “Won’t Fix,” apparently). The solution proposed on the ticket was simple enough—just use a different postgres gem.
Now, if you’ve been following the various attempts at a proper postgres gem over the years, this solution will not be new to you. On my old machine I had a total of 4 different postgres gems. On this new one, I only installed postgres-pr … until today, that is.
In this particular instance, we wanted to use the new “pg” gem, dated roundabouts October 13th, 2008. And to get that version, we would normally just do:
sudo gem install pg
But of course, since we’re on an Intel Mac using a Macport-installed version of Postgres, we will need to do something a little more verbose, like so:
sudo env ARCHFLAGS="-arch i386" gem install pg -- --with-pgsql-lib-dir=/opt/local/lib/postgresql81/ --with=pgsql-include-dir=/opt/local/include/postgresql81/
The ARCHFLAGS bit is to identify your system’s architecture, while the pgsql parameters are to indicate where your all-important Postgres files are located. (Obviously, you’ll most likely need to change the values of pgsql-lib-dir and pgsql-include-dir to match your own respective locations.)



