SELECT functions.to_global_col_names('"REF_UNIT"');

SELECT functions.rename_if_exists($$ALTER TABLE "REF_UNIT" RENAME "REF_UNIT.STATECD" TO ".STATECD"$$);
SELECT functions.rename_if_exists($$ALTER TABLE "REF_UNIT" RENAME "REF_UNIT.VALUE"   TO ".UNITCD" $$);

SELECT functions.set_col_types('"REF_UNIT"', ARRAY[
  ('.STATECD' , 'integer')
, ('.UNITCD' , 'integer')
]::functions.col_cast[]);

SELECT functions.create_if_not_exists($$ALTER TABLE "REF_UNIT" ADD CONSTRAINT "REF_UNIT.unique" UNIQUE (".STATECD", ".UNITCD")$$);
