我只是有点被Ruby on rails Tutorial.org中的这段代码迷住了.它的add_index个部分到底是做什么的?为什么这个有3行?
class CreateRelationships < ActiveRecord::Migration
def change
create_table :relationships do |t|
t.integer :follower_id
t.integer :followed_id
t.timestamps
end
add_index :relationships, :follower_id
add_index :relationships, :followed_id
add_index :relationships, [:follower_id, :followed_id], unique: true
end
end