rails g migration CreateJoinTable zombie:index role:index
这就造成这种迁移:有效地创建一个连接表迁移
class CreateJoinTable < ActiveRecord::Migration
def change
create_join_table :zombies, :roles do |t|
t.index [:zombie_id, :role_id]
t.index [:role_id, :zombie_id] # I'd be happy if it didn't have this!
end
end
end
,移民几乎是有,但为什么我有四个指标,而不是两个?在我的generate命令中,它是否指定为已经存在的索引创建额外的两组索引?
供参考:http://edgeguides.rubyonrails.org/active_record_migrations.html#creating-a-join-table 也是这样: http://edgeguides.rubyonrails.org/active_record_migrations.html#creating-独立迁移(本部分的最后部分) – sixty4bit