Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails列迁移中的'index'选项有效吗?_Ruby On Rails_Postgresql_Activerecord_Rails Migrations - Fatal编程技术网

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中它不起作用,谢谢你这么做!