SELECT functions.to_global_col_names('"PLOT"'); SELECT functions.rename_if_exists($$ALTER TABLE "PLOT" RENAME "PLOT.STATECD" TO ".STATECD" $$); SELECT functions.rename_if_exists($$ALTER TABLE "PLOT" RENAME "PLOT.UNITCD" TO ".UNITCD" $$); SELECT functions.rename_if_exists($$ALTER TABLE "PLOT" RENAME "PLOT.COUNTYCD" TO ".COUNTYCD"$$); SELECT functions.rename_if_exists($$ALTER TABLE "PLOT" RENAME "PLOT.PLOT" TO ".PLOT" $$); SELECT functions.rename_if_exists($$ALTER TABLE "PLOT" RENAME "PLOT.INVYR" TO ".INVYR" $$); SELECT functions.set_col_types('"PLOT"', ARRAY[ ('.STATECD' , 'integer') , ('.UNITCD' , 'integer') , ('.COUNTYCD', 'integer') , ('.PLOT' , 'integer') , ('.INVYR' , 'integer') ]::functions.col_cast[]); SELECT functions.create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.ID" UNIQUE ("PLOT.CN") $$); SELECT functions.create_if_not_exists($$ALTER TABLE "PLOT" ADD CONSTRAINT "PLOT.unique" UNIQUE (".STATECD", ".UNITCD", ".COUNTYCD", ".PLOT", ".INVYR")$$); SELECT functions.cluster_once('"PLOT"', '"PLOT.unique"');