Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.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 如何在续集迁移中创建hstore列?_Ruby_Postgresql_Migration_Sequel_Hstore - Fatal编程技术网

Ruby 如何在续集迁移中创建hstore列?

Ruby 如何在续集迁移中创建hstore列?,ruby,postgresql,migration,sequel,hstore,Ruby,Postgresql,Migration,Sequel,Hstore,如何在续集迁移中创建hstore列 Sequel.migration do change do add_column :logs, :geo, HStore end end 失败了。是否必须加载扩展?作为,DB在使用扩展之前需要此附加扩展: CREATE EXTENSION hstore 我在文档中找不到这个,所以我在IRC上询问 jeremyevans:使用方法_missing,允许您使用任何自定义数据库类型 因此,只要启用扩展,就可以指定json,jsonb: Seque

如何在续集迁移中创建hstore列

Sequel.migration do
  change do
    add_column :logs, :geo, HStore
  end
end
失败了。是否必须加载扩展?

作为,DB在使用扩展之前需要此附加扩展:

CREATE EXTENSION hstore

我在文档中找不到这个,所以我在IRC上询问

jeremyevans:使用方法_missing,允许您使用任何自定义数据库类型

因此,只要启用扩展,就可以指定
json
jsonb

Sequel.migration do
  change do
    create_table :foo do
      primary_key :id
      jsonb :bar
    end
  end
end
要启用扩展,请执行以下操作:

Sequel.extension :pg_json
要创建新记录,请执行以下操作:

foo = Foo.new bar: Sequel.pg_jsonb({ 'baz' => 'qux' })

我怀疑您的答案在本文档中。具体来说,请看标题PostgreSQL特定数据库类型支持感谢您为我指出了正确的文档页面,但我仍然无法运行迁移。我尝试了不同的名称,如:hstore、:h_store、:pg_hstore、hstore等。我已经加载了:pg_store DB扩展名,甚至在Gemfile中添加了sequel_pg&sequel hstore gems。尝试使用json数据类型,效果不错,但我更喜欢hstore。也许这是gem中的一个bug。您向维护人员报告了吗?我会查看,谢谢。顺便说一句,正确的行是add_列:logs、:geo、:hstore或'hstore'