Rails add_reference
Adds a reference. The reference column is a bigint by default, the :type option can be used to specify a different type. Optionally adds a _type column, if :polymorphic option is provided. add_reference and add_belongs_to are acceptable.
:index
Add an appropriate index. Defaults to true. See add_index for usage of this option.
とあるように、indexオプションでインデックスを張る際の設定を追加できる。デフォルトはtrue
オプション複雑になるとあれなので、マイグレーション分けた方がわかりやすいかもしれないosamtimizer.icon
あと、複合インデックスはここで書くと(多分)reference columnに対して単一のインデックスが張られないので分けた方が良さそう
unique indexと共にreferenceを追加する
add_reference(:products, :supplier, index: { unique: true })