Specify custom index name when using add_reference
As I commented, do :
add_index :table, :column, name: 'index name'
Here is documentation.Or, you can try this :
class LinkDoctorsAndSpecializations < ActiveRecord::Migration def change add_reference :doctors, :doctor_specialization, polymorphic: true, index: { name: 'index name' } endend
This would actually work:
add_index :table, :column, name: 'index name'
Take a look for more examples.
I would not suggest leaving out "add_reference", but you could leave out the "index" option hash key and then use "add_index":
add_reference :table, :columnadd_index :table, :column, :name => 'index_table_column'
Or, the more appropriate way would be like this:
add_reference :doctors, :doctor_specialization, polymorphic: true, index: { name: 'index_doctors_doctor_specialization' }