Specify custom index name when using add_reference

前端 未结 4 1258
生来不讨喜
生来不讨喜 2021-02-12 15:31

I have the following migration

class LinkDoctorsAndSpecializations < ActiveRecord::Migration
  def up
    add_reference :doctors, :doctor_specialization, poly         


        
4条回答
  •  面向向阳花
    2021-02-12 16:04

    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' }
      end
    end
    

提交回复
热议问题