Question

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?

Was it helpful?

Solution 2

As the Author's gem answered me, the DB needs this additional extension before using it:

CREATE EXTENSION hstore

OTHER TIPS

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' })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top