首页 文章

使用index:true命名迁移中的索引

提问于
浏览
6

我有一个迁移,在下面,我用index:true创建索引 . 但是,该索引的名称太长,所以我试图自己命名 . 但是,这似乎没有运行 . 我得到相同的“名字太长”错误 . 有没有办法用index:true命名这样的索引?如果没有,我如何用add_index命名它?

class CreateVehicleProductApplicationNotes < ActiveRecord::Migration
  def change
    create_table :vehicle_product_application_notes do |t|
      t.references :product_id, index: true
      t.references :product_application_id, index: true, :name "my_index"
      t.references :note_id, index: true

      t.timestamps
    end
  end
end

1 回答

相关问题