Dr Nic

Composite Primary Keys goes 1.0.0 for Rails 2.1

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.

Related posts:

  1. Instant new Rails applications with the App Scrolls When I start a new project I want to start...
  2. Install any HTML theme/template into your Rails app Have you ever even bothered to Google for “rails...
  3. Closing in on The Dream: “one-click-to-deploy Rails apps” Got a simple app you want to build? Allocate...
  4. Sample Rails app: multi-OpenIDs per user Last time, on “Dr Nic loves OpenID”… Dr Nic had...
  5. Magic Multi-Connections: A “facility in Rails to talk to more than one database at a time” At this point in time there’s no facility in Rails...

4 Responses to “Composite Primary Keys goes 1.0.0 for Rails 2.1”

  1. ara.t.howard says:

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

  2. 0t says:

    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. [...] Composite Primary Keys Goes 1.0.0 for Rails 2.1 – More news from Dr. Nic. [...]

  4. elhumano says:

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