Phasing in PostgreSQL
Since I like to avoid the Sun, I’ve started migrating my stuff away from MySQL and into Postgres this weekend. So far, I have a functional PostgreSQL ActiveTable driver and most of my ActiveTable demo app working with it.
Postgres isn’t bad. It’s a little confusing initially, when you can’t figure out how connecting works (it can auth based on whoami if you just want to connect via a UNIX domain socket, and it supports hashed passwords for connecting over TCP/IP, etc), but once you’re in, it’s easy. I really like phpPgAdmin - I wish phpMyAdmin was this nice.
The major differences I’ve seen between Pg and MySQL are
- No auto_increment. Instead, there’s a SERIAL type you can use that creates a sequence for you automagically.
- Timestamp doesn’t accept 0000-00-00 00:00:00 as a valid value.
- Postgres doesn’t let you specify an empty string in an integer column.
- Instead of enum, we have a CHECK() that takes in any expression. Enums are CHECK(column IN (’A',’B')).
It has some pretty ridiculous features, like arrays and polygon datatypes, too.
The only problem I’ve had thusfar is that my sequences got all fucked up when I imported my data. I specified the value for my PK columns, but the sequences stayed at 1. Easy enough to fix, though. I wrote a little script to clean things up in no time.

