这会添加索引,但不允许我设置名称。我怎样才能做到这一点?
class AddIndexEventScheduleidDayStarttime < ActiveRecord::Migration
def up
add_index(:events, [:schedule_id, :day , :start_time], {:name => "event_schedule_by_day_and_time_index"})
end
def down
remove_index(:events, {name: "event_schedule_by_day_and_time_index"})
end
end
$ rake db:migrate
== AddIndexEventScheduleidDayStarttime: migrating ============================
-- add_index(:events, [:schedule_id, :day, :start_time], {:name=>"event_schedule_by_day_and_time_index"})
-> 0.2210s
== AddIndexEventScheduleidDayStarttime: migrated (0.2212s) ===================