Reputation: 1651
How do I create a hstore column in a Sequel migration?
Sequel.migration do
change do
add_column :logs, :geo, HStore
end
end
fails. Do I have to load an extension?
Upvotes: 5
Views: 2268
Reputation: 8427
I could not find this in the documentation so I asked on IRC.
jeremyevans: method_missing is used, allowing you to use any custom database types
So you can specify json
, jsonb
as long as the extension is enabled:
Sequel.migration do
change do
create_table :foo do
primary_key :id
jsonb :bar
end
end
end
To enable the extension:
Sequel.extension :pg_json
And to create a new record:
foo = Foo.new bar: Sequel.pg_jsonb({ 'baz' => 'qux' })
Upvotes: 4
Reputation: 1651
As the Author's gem answered me, the DB needs this additional extension before using it:
CREATE EXTENSION hstore
Upvotes: 2