Ruby on rails 从外键迁移中删除_id后缀

Ruby on rails 从外键迁移中删除_id后缀,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,我正在尝试通过迁移将外键添加到。它按预期工作,但会自动将\u id添加到末尾(我要引用的列名不包括\u id)。如何使其引用我给定的列名 这里是迁移 class ChangeRefOnMemberPresentations < ActiveRecord::Migration[5.2] def change add_reference :member_presentations, 'employee_number', foreign_key: { to_table: :users

我正在尝试通过迁移将外键添加到。它按预期工作,但会自动将
\u id
添加到末尾(我要引用的列名不包括
\u id
)。如何使其引用我给定的列名

这里是迁移

class ChangeRefOnMemberPresentations < ActiveRecord::Migration[5.2]
  def change
    add_reference :member_presentations, 'employee_number', foreign_key: { to_table: :users }
  end
end
class changerefMemberPresentations

这导致引用列名和外键引用列在schema.rb中都被称为
employee\u number\u id
。下面通过手动定义所有内容来工作,但看起来很混乱。如果有更好的迁移答案,我很乐意接受

def change
  # column was added in another migration, but including for completness
  add_column :member_presentations, :employee_number, :bigint
  add_index :member_presentations, :employee_number, name: "index_member_presentations_on_employee_number"
  add_foreign_key :member_presentations, :users, column: "employee_number"
end