As for migrations, I don't actually know since I never that style of
migrations. Happy to take a patch if the answer is now.
Charlie
ActiveRecord::ConnectionAdapters::Table# Rails doesn't make it easy to add a composite primary key in a migration.# This was written to make it as easy as writing this in your migration:# t.add_primary_key [:user_id, :other_id]class ActiveRecord::ConnectionAdapters::Tablemodule AddPrimaryKeydef add_primary_key(columns)column_exists?(:id, nil, {})remove :id if column_exists?(:id, nil, {})@base.execute "alter table #{@table_name} add primary key(#{Array(columns).join(', ')})"enddef drop_primary_key@base.execute "alter table #{@table_name} drop primary key"enddef undo_add_primary_key(columns)drop_primary_keyArray(columns).each do |c|change c, :string, :null => true, :default => nilendadd_default_primary_keyenddef add_default_primary_keyinteger :id unless column_exists?(:id, nil, {})change :id, :primary_keyendendendclass ActiveRecord::ConnectionAdapters::Tableinclude AddPrimaryKeyend