迁移中有以下几个:
create_table :model_with_a_long_name do |t| t.references :other_model_with_an_equally_long_name,index: true end
这会产生一个索引,其长度不能超过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
?
解决方法
根据
Rails code for
references
,您可以这样做,为索引提供一个Hash选项,您需要调用的名称:name,so:
t.references :my_field,index: { name: 'my_index_name' }
原文地址:https://www.jb51.cc/ruby/273037.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。