rails g migration add_product_images_index
db/migrate/20170119093958_add_product_images_index.rb
class AddProductImagesIndex < ActiveRecord::Migration[5.0] def change add_index :product_images, [:product_id, :weight] #创建联合索引 end end
rake db:migrate