Postgres alter multiple columns to citext type

391 Views Asked by At

We need to change 206 fields in multiple tables to data_type citext (extension). I've created the extension and manually changed a column to see what it should look like in the schema. The data_type needs to be USER-DEFINED and column_default needs to be ''::citext however I can't get this to work.

ALTER TABLE {tablename} ALTER COLUMN data_type USER-DEFINED;

ALTER TABLE {tablename} ALTER COLUMN column_default CONCAT('''','''','::citext'); 

Update 6/15 I was able to successfully update the type with

ALTER TABLE {table_name} ALTER COLUMN {column_name} TYPE citext;

However, I still have a concern that when looking at the properties of the column, under the constraints tab, the Default value is ''::bpchar and not ''::citext like the manuallly change columns.

enter image description here

0

There are 0 best solutions below