SELECT functions.to_global_col_names('"TREE"'); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.STATECD" TO ".STATECD" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.UNITCD" TO ".UNITCD" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.COUNTYCD" TO ".COUNTYCD"$$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.PLOT" TO ".PLOT" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.INVYR" TO ".INVYR" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.CONDID" TO ".CONDID" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.SUBP" TO ".SUBP" $$); SELECT functions.rename_if_exists($$ALTER TABLE "TREE" RENAME "TREE.SPCD" TO ".SPCD" $$); SELECT functions.set_col_types('"TREE"', ARRAY[ ('.STATECD' , 'integer') , ('.UNITCD' , 'integer') , ('.COUNTYCD', 'integer') , ('.PLOT' , 'integer') , ('.INVYR' , 'integer') , ('.SUBP' , 'integer') , ('.CONDID' , 'integer') , ('.SPCD' , 'integer') ]::functions.col_cast[]); -- ("STATECD", "UNITCD", "COUNTYCD", "PLOT", "INVYR", "CONDID", "SUBP", "TREE", "STATUSCD") is not ID SELECT functions.create_if_not_exists($$ALTER TABLE "TREE" ADD CONSTRAINT "TREE.ID" UNIQUE ("TREE.CN")$$); SELECT functions.cluster_once('"TREE"', '"TREE.ID"'); SELECT functions.create_if_not_exists($$CREATE INDEX "TREE.parent" ON "TREE" (".STATECD", ".UNITCD", ".COUNTYCD", ".PLOT", ".INVYR", ".CONDID", ".SUBP")$$);