kaleidos / grails-postgresql-extensions

Grails plugin to use postgresql native elements such as arrays, hstores,...
Apache License 2.0
78 stars 62 forks source link

json vs jsonb #59

Closed domiko closed 9 years ago

domiko commented 9 years ago

Hi guys, Thanks for a great plugin.

I've tried re-mapping a gorm field from json to jsonb. However, pgAdmin still lists the field as json (not jsonb).

Regards

ilopmar commented 9 years ago

Hi.

I think that hibernate is not capable of modifying the column type even if you have set your DataSource.groovy dbCreate property to update.

You can always modify the type of the column using pgAdmin or psql:

ALTER TABLE my_table ALTER COLUMN my_column_of_type_json TYPE jsonb USING my_column_of_type_json::jsonb;

Please note that the USING clause is necessary because postgresql doesn't know how to convert directly from json to jsonb.

I hope this helps.

domiko commented 9 years ago

Thank Ivan for your very quick reply. Your tip works like a charm.

Thanks, Dominique

ilopmar commented 9 years ago

Great! :-)