Hi,
I have field in postgres (9.2.4) with type json. The field looks like
Column | Type | Modifiers | Storage
|
Stats target | Description
---------------------±----------------------------±----------±---------±-------------±------------
my_id_field | json | |
extended
| |
When I do " select my_id_field::json from table1", it returns something
like
[]
[]
[]
[“abc”]
[]
[]
[]
I like to change this from type json to text[] and included the
following
in the migration
execute “alter table table1 add column new_id_field text[] default
‘{}’::text[]”
execute “UPDATE table1 SET new_id_field = [my_id_field] where
my_id_field
is not null”
I ended up with data like [[“abc”]] and [[]], which was not what I
wanted
Questions:
- how do I convert the json type to text[]?
- in ActiveRecord, how do I select rows from table1 that are not []?
TIA
m