SELECT functions.to_global_col_names(:table_str); 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(:table_str, 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")$$);