I am trying to change the type of one of the columns on my table from one that takes arrays filled with strings to one that takes JSON. The SQL I'm trying to execute looks like:
ALTER TABLE my_table
ALTER COLUMN my_column TYPE JSON USING my_column::json
But I get an error back saying "cannot cast type character varying[] to json". The column I'm trying to change is empty, there are no rows so there is no data that needs to be cast to JSON. Since it's empty I've thought of dropping the column and remaking it but I'd like to keep the column and just change its type if possible. I'm not a whizz with PostgreSQL so any nudge in the right direction would be appreciated.
select array_to_json(null::varchar[]); NULL