Upgrading postgres on Snow Leopard (Mac OS X 10.6)
Well, I too have gone down the rabbit hole of having to upgrade compiled-from-source apps to 64bit architecture after moving to Snow Leopard. The hardest by far was postgres. The sad thing is that 32bit version works just fine, but the adapter gems for rails don’t, hence the need for the recompile.
Mostly I followed this blog post, but it assumes that you had previously installed postgres using his instructions for Leopard which I hadn’t.
My previous installation was at /usr/local/postgres and these instructions end up installing it at /usr/local/pgsql, so my task also includes getting the data from my previous installation to the new on.
I also took some some hints from this post.
Here’s the blow by blow:
Make a backup of all my data from the 32bit version:
Switch to super user, make a directory for the source (if you haven’t already), download and extract it:
Now configure, make and install it:
Then I followed the instructions from the above mentioned blog on how to make a postgres user, but I did them in a different terminal window because remember the other one we were logged in as root:
“First, you’ll need to find an unused user and group ID. Use the following commands to list the IDs for the users and groups on your system.”
“For the purposes of this tutorial, let’s assume an ID of 113 for both the user and the group. Since the convention is to prefix system accounts with an underscore, use the following commands to create a user called _postgres:”
“Then, create the _postgres group:”
So at this point the binaries are installed and there’s a user to run it under, but I needed to initialize a new database and copy back in my saved data. First create the data and log directories and set perms:
Then I logged in as the _postgres user:
And initialize database files and start up the database:
Finally I restored the data from my initial pg_dumpall
I’ve also added these lines into my .profile to add the commands to my path and to simplify starting and stopping the database:
And then finally I could install the postgres rails gem (which was the whole point of this silly excercise):