CD Baby rewrite in Postgres and Ruby, Baby!

Email.Email weblog link
Blog this.Blog this
Derek Sivers

Derek Sivers
Jan. 22, 2005 04:09 PM

Atom feed for this author. RSS 1.0 feed for this author. RSS 2.0 feed for this author.


I know I've talked about it sporadically for a year now, (see past posts), but I've finally started my CD Baby rewrite.

BIG CHANGE #1 : PostgreSQL

I dabbled with PostgreSQL one night when I wasn't in the mood to do what I was supposed to be doing. I'd heard some people I respect rave about it, and since I really do love databases, I decided it was worth a few hours of my time. Holy Canoli! Its strictness solves most of my data corruption problems I've had with MySQL!

Example problems with CD Baby database in MySQL:

#1 - entries deleted from one table that were required by another.
Example: An album is deleted from our catalog, so now all the lineitems (customer purchases) of that album are left dangling with no matching identifier.

#2 - many invalid entries, especially many dates of "0000-00-00"
This one has gotten us into trouble with our digital distribution partners, whose much-smarter system throw up a big fat error when we stupidly report an album's release date as "0000-00-00"

#3 - no strict requiring of join-ids matching.
Example: someone mistakenly entering that an order belongs to customer #314981 when it should have been #319481, and there is no customer #314981. Database didn't complain so we didn't notice.

Yes of course with these and every other example we all say, "Yeah but your code should have prevented that." Thing is : in MOST places it does, but various little shell scripts and admin scripts can't check for every possible human error, so here I am with a constantly corrupt database.

This is where I *LOVE* the strictness that PostgreSQL makes easy. Yes I hear that MySQL InnoDB tables do the same thing, but I've already fallen in love with PostgreSQL, and switched.


Like a lost soul walkin' the earth, lookin' for spirituality, that stumbles upon the right church with the right people at the right time, I've found my niche with Ruby. Its little itty-bitty community attracts some brilliant "think different" types with a love for beautiful code that do this for love, not money.

I liked it immediately a year ago when I learned it while stuck in a cabin in Sweden. I stopped after some shell scripts though because its web-making features weren't up to snuff. Now, with Rails, there are a team of passionate geniuses contributing to this web-making framework daily. It's small enough that you can stay on top of it, and watch this framework get more and more powerful by the week. Improvements that are pragmatic not political. People using it to make effective websites, contributing to the shared framework around it as they go. Why not take advantage of all this brilliant work?

It took a lot to get me to switch from PHP, the only language I really know, to Ruby. I tell my non-computer friends, "It's like the week before sitting down to write a book, I decided to write it in Portuguese instead of English, because it'll be easier." It sounds crazy, but we'll see.

Bookmark/subscribe to my author page, here, at if you want to watch the almost-daily developments.

Derek Sivers is the founder, president, and sole programmer behind CD Baby, independent music distribution, and HostBaby, web hosting for musicians.