Ruby on rails Rails列迁移中的'index'选项有效吗?
我可以编写如下迁移:Ruby on rails Rails列迁移中的'index'选项有效吗?,ruby-on-rails,postgresql,activerecord,rails-migrations,Ruby On Rails,Postgresql,Activerecord,Rails Migrations,我可以编写如下迁移: class CreateFoos < ActiveRecord::Migration def change create_table :foos do |t| t.string :bar, index: true end end end class CreateFoos4.2的升级很简单)。我很确定它只对数字有效,因为索引是用来加速关联检索的。在Rails 4.2中,你的确切代码对我有效,db/schema.rb最后是:添加索引“
class CreateFoos < ActiveRecord::Migration
def change
create_table :foos do |t|
t.string :bar, index: true
end
end
end
class CreateFoos
根据index:true
还应该为该列上的表创建一个索引,但是我可以在schema.rb
中看到它没有
这是一个已知的错误还是与我的设置有关?FWIW我在Rails 4.1.8上使用Postgres和PostGIS
这也不适用于
t的较长语法。column:bar,:string,index:true
虽然它似乎适用于t。它属于,因此,经确认,这与4.1.8和4.1.9中所宣传的不一样,是的,这是一个错误
这个错误在4.2.0中得到了修复(4.1->4.2的升级很简单)。我很确定它只对数字有效,因为索引是用来加速关联检索的。在Rails 4.2中,你的确切代码对我有效,db/schema.rb
最后是:添加索引“foos”[“bar”],名字是:“index\foos\u on\u on\u bar”
。不过你是对的,在4.1.8中它不起作用,谢谢你这么做!