【发布时间】:2013-11-22 20:17:50
【问题描述】:
我只是有点卡在 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
【问题讨论】:
标签: ruby-on-rails ruby database indexing