如何在Sequel迁移中创建hstore列?如何在续集迁移中创建hstore列?
Sequel.migration do
change do
add_column :logs, :geo, HStore
end
end
失败。我需要加载扩展吗?
如何在Sequel迁移中创建hstore列?如何在续集迁移中创建hstore列?
Sequel.migration do
change do
add_column :logs, :geo, HStore
end
end
失败。我需要加载扩展吗?
随着Author's gem answered me,数据库需要这种额外的扩展使用它之前:
CREATE EXTENSION hstore
顺便说一句,正确的行是add_column:logs,:geo,:hstore#或'hstore' – MegaTux
的文档中我找不到这个所以我要求在IRC上。
jeremyevans:method_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' })
我怀疑你的答案就在于这个文档,http://sequel.jeremyevans.net/rdoc/files/doc/postgresql_rdoc.html英寸具体来说,看标题** PostgreSQL特定的数据库类型支持** –
感谢您指向我正确的文档页面,但我仍然无法运行迁移。我尝试了不同的名称,例如:hstore,:h_store,:pg_hstore,HStore等。我已经加载了:pg_store数据库扩展,甚至将sequel_pg和sequel-hstore gems添加到Gemfile中。试过用json数据类型,并行得通,但我更喜欢hstore。 – MegaTux
也许这是宝石中的一个错误。你有报告给维护者吗? –