相关疑难解决方法(0)

迁移:t.references不允许指定索引名称

我在迁移中有以下内容:

create_table :model_with_a_long_name do |t|
  t.references :other_model_with_an_equally_long_name, index: true
end
Run Code Online (Sandbox Code Playgroud)

这会为Postgres产生一个名字太长的索引.

有没有办法手动指定索引名称(不分别添加整数列和索引)?

类似于以下内容:

create_table :model_with_a_long_name do |t|
  t.references :other_model_with_an_equally_long_name, index: true, index_name: 'model_and_other'
end
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

32
推荐指数
1
解决办法
9285
查看次数

标签 统计

ruby ×1

ruby-on-rails ×1