So I'm starting to use the Postgres JSON datatype, now that there's a lot of fun stuff you can do with it. In one of my Rails apps which is not yet Rails 4 (where support for Postgres JSON has been added) I added a JSON column like this:
create_table :foo do |t|
t.column :bar, :json
end
but I can't figure out how to set a default value for the column.
I tried all variations like {}
, '{}'
, '{}'::json
, '[]'::json
etc. but I either get an error when the migration runs or it simply doesn't work, meaning the migration runs but, when I create a new Foo
, bar
is nil
.