I’m trying to convert a HABTM w/attributes join table in my database
into a join model table in order to utilize the new has_many :through
functionality introduced in Rails 1.1. Here’s the current table
licenses_user_groups: license_id, user_group_id, usage_notes
Perhaps it was a mistake, but I made (license_id, user_group_id) the
Now, after playing with has_many :through, I have discovered that, among
other modifications, I really need to add an id column to the table and
make it the primary key. However, I cannot figure out how to use the
SchemaStatements to add the new column, set it to auto-increment, and
then redefine the primary key to be the id column instead of the
(license_id, user_group_id) columns.
I could use the execute statement and use SQL directly, but I would
prefer not to (one of the reasons behind migrations, I thought, was to
provide a DB independent way of creating and modifying schemas; using
SQL directly makes it possible and likely that database specific changes
will be introducted).
Any help (or confirmation that execute is the only way to do what I’m
looking to do) would be appreciated.