Composite Primary Keys goes 1.0.0 for Rails 2.1

Posted by Dr Nic on June 06, 2008

Two years ago Dave Thomas did a keynote at the first RailsConf in 2006 and outlined a few things missing in Rails. One was the seeming unnecessary un-DRYness of duplicating associations and validations in Active Record models since the same information is in the DB schema. Another was support for Composite Primary Keys on Active Record models.

A few weeks later I created my first RubyGems as an attempt to solve these problems: Dr Nic’s Magic Models and Composite Primary Keys. The former was funny and an entertaining way to use const_missing? and Class.new. The latter was not funny. It started at the heights of “mildly entertaining,” dropped down from there and then over the subsequent months it never again rose above the humour-scale heights of “please shoot me in the foot.”

There were entire months that I hated ever having created the Composite Primary Keys project :)

Why? It sits precariously atop of ActiveRecord::Base, and a half dozen other ActiveRecord classes. It overrides methods, recreates entire blocks of SQL, and must work on all the different database adapters. That is, it is very sensitive to many changes in edge Rails. And refactoring ActiveRecord is a favourite pastime of the Rails Core team.

Unlike the Magic Models project which is perfectly useful for party tricks but probably partially pointless elsewhere, the CPK project just seemed to be so damned useful to some people.

Many people kept using it, several people contributed patches for adapter support and new features, and finally the Prophet arrived. The man that would lead the faithful forward to the Promised Land.

His name is Darrin “Champion” Holst.

Today, CPK was given the golden release number 1.0.0 and officially supports Rails 2.1 (but no longer supports 2.0.2 afaik).

CPK users might remember that we went 0.9.90 back in January, and its now June. This led Darrin to comment in his release email to the mailing list:

I’d like to name this release the “we’re running out of 0.9.x numbers, so it has to go to 1.0 sooner or later” release.

Maintaining CPK is like being on the team that paints the Sydney Harbour Bridge - it takes then 12 mths to paint it from one end to the other, which is just in time to restart painting the bloody thing again.

So in every way that I (tried to) abandon the project, I am proud of Darrin for looking after it and all its users.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. ara.t.howard Fri, 06 Jun 2008 14:46:08 UTC

    Good work both of you - know you just need to fork AR on github ;-)

  2. 0t Sat, 07 Jun 2008 00:14:58 UTC

    I just want you to know that I view this project as essential to rails adoption in the enterprise space. We use it extensively against a legacy Oracle database.
    Thanks everyone for your efforts.

  3. A Fresh Cup » Blog Archive » Double Shot #225 Mon, 09 Jun 2008 20:21:40 UTC

    [...] Composite Primary Keys Goes 1.0.0 for Rails 2.1 - More news from Dr. Nic. [...]

  4. elhumano Fri, 08 Aug 2008 03:35:34 UTC

    Yes, good idea, fork AR with composite primary keys support, it´s the solution for enterprise legacy apps.

Comments