-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: TNRS; Type: SCHEMA; Schema: -; Owner: - -- --CREATE SCHEMA "TNRS"; -- -- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: - -- COMMENT ON SCHEMA "TNRS" IS ' IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev: on vegbiendev: # back up existing TNRS schema (in case of an accidental incorrect change): $ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s") $ svn up $ svn di # make the changes shown in the diff ## to change column types: SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[ (''col'', ''new_type'') ]::util.col_cast[]); -- runtime: 9 min ("531282 ms") $ rm=1 inputs/.TNRS/schema.sql.run # repeat until `svn di` shows no diff # back up new TNRS schema: $ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s") '; SET search_path = "TNRS", pg_catalog; -- -- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION batch__fill() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN new.id_by_time = new.time_submitted; new.id = COALESCE(new.id, new.id_by_time); RETURN new; END; $$; -- -- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION family_is_homonym(family text) RETURNS boolean LANGUAGE sql STABLE STRICT AS $_$ SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1) $_$; -- -- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean LANGUAGE sql STABLE STRICT AS $_$ SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1) $_$; -- -- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ /* from http://wiki.vegpath.org/2013-11-14_conference_call#taxonomic-fields: "taxonomic_status should be accepted instead of synonym when an accepted name is available (this is not always the case when a name is marked as a synonym)" */ SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END $_$; -- -- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0); RETURN NULL; END; $$; -- -- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_match__fill() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN DECLARE "Specific_epithet_is_plant" boolean := (CASE WHEN new."Infraspecific_epithet_matched" IS NOT NULL OR new."Infraspecific_epithet_2_matched" IS NOT NULL OR new."Specific_epithet_score" >= 0.9 -- fuzzy match THEN true ELSE NULL -- ambiguous END); never_homonym boolean = COALESCE(new."Author_score" >= 0.6, false); -- author disambiguates family_is_homonym boolean = NOT never_homonym AND "TNRS".family_is_homonym(new."Family_matched"); genus_is_homonym boolean = NOT never_homonym AND "TNRS".genus_is_homonym(new."Genus_matched"); BEGIN /* exclude homonyms because these are not valid matches (TNRS provides a name, but the name is not meaningful because it is not unambiguous) */ new.is_valid_match = new."Taxonomic_status" != 'Invalid' AND COALESCE(CASE WHEN new."Family_score" = 1 AND NOT family_is_homonym -- exact match THEN true ELSE -- consider genus (CASE WHEN new."Genus_score" = 1 -- exact match THEN (CASE WHEN NOT genus_is_homonym THEN true ELSE "Specific_epithet_is_plant" END) WHEN new."Genus_score" >= 0.85 -- fuzzy match THEN "Specific_epithet_is_plant" ELSE NULL -- ambiguous END) END, false); END; DECLARE matched_taxon_name_with_author text = NULLIF(concat_ws(' ' , NULLIF(NULLIF(new."Name_matched_accepted_family", 'Unknown'), new."Name_matched") , NULLIF(new."Name_matched", 'No suitable matches found.') , new."Name_matched_author" ), ''); accepted_taxon_name_with_author text = NULLIF(concat_ws(' ' , NULLIF(NULLIF(new."Accepted_name_family", 'Unknown'), new."Accepted_name") , new."Accepted_name" , new."Accepted_name_author" ), ''); BEGIN new.scrubbed_unique_taxon_name = COALESCE( accepted_taxon_name_with_author, matched_taxon_name_with_author); END; RETURN new; END; $$; -- -- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON FUNCTION taxon_match__fill() IS ' IMPORTANT: when changing this function, you must regenerate the derived cols: UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted" runtime: 30 min ("5564082 rows affected, 1918900 ms execution time") VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows runtime: 1.5 min ("92633 ms") '; -- -- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF new.match_num IS NULL THEN new.match_num = "TNRS".taxon_match__match_num__next(); END IF; RETURN new; END; $$; -- -- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint LANGUAGE sql AS $$ SELECT nextval('pg_temp.taxon_match__match_num__seq'); $$; -- -- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN INSERT INTO "TNRS".taxon_match_input SELECT new.*; RETURN NULL; END; $$; -- -- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean LANGUAGE sql IMMUTABLE AS $_$ SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names())) $_$; -- -- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: - -- CREATE FUNCTION unsafe_taxon_names() RETURNS text[] LANGUAGE sql IMMUTABLE AS $$ SELECT ARRAY[ ]::text[] $$; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: -- CREATE TABLE taxon_match ( batch text DEFAULT now() NOT NULL, match_num integer NOT NULL, "Name_number" integer NOT NULL, "Name_submitted" text NOT NULL, "Overall_score" double precision, "Name_matched" text, "Name_matched_rank" text, "Name_score" double precision, "Name_matched_author" text, "Name_matched_url" text, "Author_matched" text, "Author_score" double precision, "Family_matched" text, "Family_score" double precision, "Name_matched_accepted_family" text, "Genus_matched" text, "Genus_score" double precision, "Specific_epithet_matched" text, "Specific_epithet_score" double precision, "Infraspecific_rank" text, "Infraspecific_epithet_matched" text, "Infraspecific_epithet_score" double precision, "Infraspecific_rank_2" text, "Infraspecific_epithet_2_matched" text, "Infraspecific_epithet_2_score" double precision, "Annotations" text, "Unmatched_terms" text, "Taxonomic_status" text, "Accepted_name" text, "Accepted_name_author" text, "Accepted_name_rank" text, "Accepted_name_url" text, "Accepted_name_species" text, "Accepted_name_family" text, "Selected" text, "Source" text, "Warnings" text, "Accepted_name_lsid" text, is_valid_match boolean NOT NULL, scrubbed_unique_taxon_name text ); -- -- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON TABLE taxon_match IS ' to remove columns or add columns at the end: $ rm=1 inputs/.TNRS/data.sql.run $ make schemas/remake to add columns in the middle: make the changes in inputs/.TNRS/schema.sql $ inputs/.TNRS/data.sql.run refresh # re-run TNRS $ make schemas/remake to populate a new column: ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update UPDATE "TNRS".taxon_match SET "col" = value; -- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time") ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill; VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms") to add a constraint: runtime: 3 min ("173620 ms") '; -- -- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW taxon_best_match AS SELECT taxon_match.batch, taxon_match.match_num, taxon_match."Name_number", taxon_match."Name_submitted", taxon_match."Overall_score", taxon_match."Name_matched", taxon_match."Name_matched_rank", taxon_match."Name_score", taxon_match."Name_matched_author", taxon_match."Name_matched_url", taxon_match."Author_matched", taxon_match."Author_score", taxon_match."Family_matched", taxon_match."Family_score", taxon_match."Name_matched_accepted_family", taxon_match."Genus_matched", taxon_match."Genus_score", taxon_match."Specific_epithet_matched", taxon_match."Specific_epithet_score", taxon_match."Infraspecific_rank", taxon_match."Infraspecific_epithet_matched", taxon_match."Infraspecific_epithet_score", taxon_match."Infraspecific_rank_2", taxon_match."Infraspecific_epithet_2_matched", taxon_match."Infraspecific_epithet_2_score", taxon_match."Annotations", taxon_match."Unmatched_terms", taxon_match."Taxonomic_status", taxon_match."Accepted_name", taxon_match."Accepted_name_author", taxon_match."Accepted_name_rank", taxon_match."Accepted_name_url", taxon_match."Accepted_name_species", taxon_match."Accepted_name_family", taxon_match."Selected", taxon_match."Source", taxon_match."Warnings", taxon_match."Accepted_name_lsid", taxon_match.is_valid_match, taxon_match.scrubbed_unique_taxon_name FROM taxon_match WHERE (taxon_match."Selected" = 'true'::text); -- -- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON VIEW taxon_best_match IS ' to modify: SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$ SELECT __ $$); '; -- -- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW "MatchedTaxon" AS SELECT taxon_best_match.batch, taxon_best_match.match_num, taxon_best_match."Name_number", taxon_best_match."Name_submitted", taxon_best_match."Overall_score", taxon_best_match."Name_matched", taxon_best_match."Name_matched_rank", taxon_best_match."Name_score", taxon_best_match."Name_matched_author", taxon_best_match."Name_matched_url", taxon_best_match."Author_matched", taxon_best_match."Author_score", taxon_best_match."Family_matched", taxon_best_match."Family_score", taxon_best_match."Name_matched_accepted_family", taxon_best_match."Genus_matched", taxon_best_match."Genus_score", taxon_best_match."Specific_epithet_matched", taxon_best_match."Specific_epithet_score", taxon_best_match."Infraspecific_rank", taxon_best_match."Infraspecific_epithet_matched", taxon_best_match."Infraspecific_epithet_score", taxon_best_match."Infraspecific_rank_2", taxon_best_match."Infraspecific_epithet_2_matched", taxon_best_match."Infraspecific_epithet_2_score", taxon_best_match."Annotations", taxon_best_match."Unmatched_terms", taxon_best_match."Taxonomic_status", taxon_best_match."Accepted_name", taxon_best_match."Accepted_name_author", taxon_best_match."Accepted_name_rank", taxon_best_match."Accepted_name_url", taxon_best_match."Accepted_name_species", taxon_best_match."Accepted_name_family", taxon_best_match."Selected", taxon_best_match."Source", taxon_best_match."Warnings", taxon_best_match."Accepted_name_lsid", taxon_best_match.is_valid_match, taxon_best_match.scrubbed_unique_taxon_name, map_taxonomic_status(taxon_best_match."Taxonomic_status", taxon_best_match."Accepted_name") AS "taxonomicStatus", CASE WHEN (taxon_best_match."Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."Accepted_name_family", taxon_best_match."Unmatched_terms") WHEN (taxon_best_match."Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."Accepted_name", taxon_best_match."Unmatched_terms") ELSE taxon_best_match."Accepted_name_species" END AS accepted_morphospecies_binomial FROM taxon_best_match; -- -- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON VIEW "MatchedTaxon" IS ' to modify: SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$ SELECT __ $$); '; -- -- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW "ValidMatchedTaxon" AS SELECT "MatchedTaxon".batch, "MatchedTaxon".match_num, "MatchedTaxon"."Name_number", "MatchedTaxon"."Name_submitted", "MatchedTaxon"."Overall_score", "MatchedTaxon"."Name_matched", "MatchedTaxon"."Name_matched_rank", "MatchedTaxon"."Name_score", "MatchedTaxon"."Name_matched_author", "MatchedTaxon"."Name_matched_url", "MatchedTaxon"."Author_matched", "MatchedTaxon"."Author_score", "MatchedTaxon"."Family_matched", "MatchedTaxon"."Family_score", "MatchedTaxon"."Name_matched_accepted_family", "MatchedTaxon"."Genus_matched", "MatchedTaxon"."Genus_score", "MatchedTaxon"."Specific_epithet_matched", "MatchedTaxon"."Specific_epithet_score", "MatchedTaxon"."Infraspecific_rank", "MatchedTaxon"."Infraspecific_epithet_matched", "MatchedTaxon"."Infraspecific_epithet_score", "MatchedTaxon"."Infraspecific_rank_2", "MatchedTaxon"."Infraspecific_epithet_2_matched", "MatchedTaxon"."Infraspecific_epithet_2_score", "MatchedTaxon"."Annotations", "MatchedTaxon"."Unmatched_terms", "MatchedTaxon"."Taxonomic_status", "MatchedTaxon"."Accepted_name", "MatchedTaxon"."Accepted_name_author", "MatchedTaxon"."Accepted_name_rank", "MatchedTaxon"."Accepted_name_url", "MatchedTaxon"."Accepted_name_species", "MatchedTaxon"."Accepted_name_family", "MatchedTaxon"."Selected", "MatchedTaxon"."Source", "MatchedTaxon"."Warnings", "MatchedTaxon"."Accepted_name_lsid", "MatchedTaxon".is_valid_match, "MatchedTaxon".scrubbed_unique_taxon_name, "MatchedTaxon"."taxonomicStatus", "MatchedTaxon".accepted_morphospecies_binomial FROM "MatchedTaxon" WHERE "MatchedTaxon".is_valid_match; -- -- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON VIEW "ValidMatchedTaxon" IS ' to update, use * as the column list '; -- -- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: -- CREATE TABLE batch ( id text NOT NULL, id_by_time text, time_submitted timestamp with time zone DEFAULT now(), client_version text ); -- -- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: -- CREATE TABLE batch_download_settings ( id text NOT NULL, "E-mail" text, "Id" text, "Job type" text, "Contains Id" boolean, "Start time" text, "Finish time" text, "TNRS version" text, "Sources selected" text, "Match threshold" double precision, "Classification" text, "Allow partial matches?" boolean, "Sort by source" boolean, "Constrain by higher taxonomy" boolean ); -- -- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON TABLE batch_download_settings IS ' stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt '; -- -- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: -- CREATE TABLE client_version ( id text NOT NULL, global_rev integer NOT NULL, "/lib/tnrs.py rev" integer, "/bin/tnrs_db rev" integer ); -- -- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON TABLE client_version IS ' contains svn revisions '; -- -- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON COLUMN client_version.global_rev IS ' from `svn info .` > Last Changed Rev '; -- -- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS ' from `svn info lib/tnrs.py` > Last Changed Rev '; -- -- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS ' from `svn info bin/tnrs_db` > Last Changed Rev '; -- -- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW taxon_match_input AS SELECT taxon_match."Name_number", taxon_match."Name_submitted", taxon_match."Overall_score", taxon_match."Name_matched", taxon_match."Name_matched_rank", taxon_match."Name_score", taxon_match."Name_matched_author", taxon_match."Name_matched_url", taxon_match."Author_matched", taxon_match."Author_score", taxon_match."Family_matched", taxon_match."Family_score", taxon_match."Name_matched_accepted_family", taxon_match."Genus_matched", taxon_match."Genus_score", taxon_match."Specific_epithet_matched", taxon_match."Specific_epithet_score", taxon_match."Infraspecific_rank", taxon_match."Infraspecific_epithet_matched", taxon_match."Infraspecific_epithet_score", taxon_match."Infraspecific_rank_2", taxon_match."Infraspecific_epithet_2_matched", taxon_match."Infraspecific_epithet_2_score", taxon_match."Annotations", taxon_match."Unmatched_terms", taxon_match."Taxonomic_status", taxon_match."Accepted_name", taxon_match."Accepted_name_author", taxon_match."Accepted_name_rank", taxon_match."Accepted_name_url", taxon_match."Accepted_name_species", taxon_match."Accepted_name_family", taxon_match."Selected", taxon_match."Source", taxon_match."Warnings", taxon_match."Accepted_name_lsid" FROM taxon_match; -- -- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: -- CREATE TABLE taxon_match_input__copy_to ( "Name_number" integer, "Name_submitted" text, "Overall_score" double precision, "Name_matched" text, "Name_matched_rank" text, "Name_score" double precision, "Name_matched_author" text, "Name_matched_url" text, "Author_matched" text, "Author_score" double precision, "Family_matched" text, "Family_score" double precision, "Name_matched_accepted_family" text, "Genus_matched" text, "Genus_score" double precision, "Specific_epithet_matched" text, "Specific_epithet_score" double precision, "Infraspecific_rank" text, "Infraspecific_epithet_matched" text, "Infraspecific_epithet_score" double precision, "Infraspecific_rank_2" text, "Infraspecific_epithet_2_matched" text, "Infraspecific_epithet_2_score" double precision, "Annotations" text, "Unmatched_terms" text, "Taxonomic_status" text, "Accepted_name" text, "Accepted_name_author" text, "Accepted_name_rank" text, "Accepted_name_url" text, "Accepted_name_species" text, "Accepted_name_family" text, "Selected" text, "Source" text, "Warnings" text, "Accepted_name_lsid" text ); -- -- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS SELECT taxon_match."Name_submitted" AS scrubbed_unique_taxon_name, taxon_match."Name_matched_rank" AS scrubbed_taxon_rank, COALESCE(taxon_match."Name_matched_accepted_family", taxon_match."Family_matched") AS scrubbed_family, taxon_match."Genus_matched" AS scrubbed_genus, taxon_match."Specific_epithet_matched" AS scrubbed_specific_epithet, taxon_match."Infraspecific_rank" AS scrubbed_infraspecific_rank, taxon_match."Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet, taxon_match."Name_matched_author" AS scrubbed_author, taxon_match."Name_matched" AS scrubbed_taxon_name_no_author, (taxon_match."Name_matched" || COALESCE((' '::text || taxon_match."Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author FROM taxon_match; -- -- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS ' to modify: SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$ SELECT __ $$); scrubbed_family: Name_matched_accepted_family was missing from the TNRS results at one point, so Family_matched is used as a workaround to populate this. the workaround is for *accepted names only*, as no opinion names do not have an Accepted_name_family to prepend to the scrubbed name to parse. '; -- -- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: - -- CREATE VIEW taxon_scrub AS SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name, "ValidMatchedTaxon".batch, "ValidMatchedTaxon".match_num, "ValidMatchedTaxon"."Name_number", "ValidMatchedTaxon"."Name_submitted", "ValidMatchedTaxon"."Overall_score", "ValidMatchedTaxon"."Name_matched", "ValidMatchedTaxon"."Name_matched_rank", "ValidMatchedTaxon"."Name_score", "ValidMatchedTaxon"."Name_matched_author", "ValidMatchedTaxon"."Name_matched_url", "ValidMatchedTaxon"."Author_matched", "ValidMatchedTaxon"."Author_score", "ValidMatchedTaxon"."Family_matched", "ValidMatchedTaxon"."Family_score", "ValidMatchedTaxon"."Name_matched_accepted_family", "ValidMatchedTaxon"."Genus_matched", "ValidMatchedTaxon"."Genus_score", "ValidMatchedTaxon"."Specific_epithet_matched", "ValidMatchedTaxon"."Specific_epithet_score", "ValidMatchedTaxon"."Infraspecific_rank", "ValidMatchedTaxon"."Infraspecific_epithet_matched", "ValidMatchedTaxon"."Infraspecific_epithet_score", "ValidMatchedTaxon"."Infraspecific_rank_2", "ValidMatchedTaxon"."Infraspecific_epithet_2_matched", "ValidMatchedTaxon"."Infraspecific_epithet_2_score", "ValidMatchedTaxon"."Annotations", "ValidMatchedTaxon"."Unmatched_terms", "ValidMatchedTaxon"."Taxonomic_status", "ValidMatchedTaxon"."Accepted_name", "ValidMatchedTaxon"."Accepted_name_author", "ValidMatchedTaxon"."Accepted_name_rank", "ValidMatchedTaxon"."Accepted_name_url", "ValidMatchedTaxon"."Accepted_name_species", "ValidMatchedTaxon"."Accepted_name_family", "ValidMatchedTaxon"."Selected", "ValidMatchedTaxon"."Source", "ValidMatchedTaxon"."Warnings", "ValidMatchedTaxon"."Accepted_name_lsid", "ValidMatchedTaxon".is_valid_match, "ValidMatchedTaxon"."taxonomicStatus", "ValidMatchedTaxon".accepted_morphospecies_binomial, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author, CASE WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'family'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, "ValidMatchedTaxon"."Unmatched_terms") WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'genus'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, "ValidMatchedTaxon"."Unmatched_terms") ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet) END AS scrubbed_morphospecies_binomial FROM ("ValidMatchedTaxon" LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name)); -- -- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: - -- COMMENT ON VIEW taxon_scrub IS ' to modify: SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$ SELECT __ $$); '; -- -- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: -- ALTER TABLE ONLY batch_download_settings ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id); -- -- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: -- ALTER TABLE ONLY batch ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time); -- -- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: -- ALTER TABLE ONLY batch ADD CONSTRAINT batch_pkey PRIMARY KEY (id); -- -- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: -- ALTER TABLE ONLY client_version ADD CONSTRAINT client_version_pkey PRIMARY KEY (id); -- -- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: -- ALTER TABLE ONLY taxon_match ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num); -- -- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: -- CREATE INDEX batch_client_version_idx ON batch USING btree (client_version); -- -- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: -- CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("Name_submitted") WHERE (("Selected" = 'true'::text) AND is_valid_match); -- -- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: -- CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("Name_submitted"); -- -- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: -- CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "Name_number") WHERE ("Selected" = 'true'::text); -- -- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: - -- CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill(); -- -- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: - -- CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin(); -- -- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: - -- CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill(); -- -- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: - -- CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill(); -- -- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: - -- CREATE TRIGGER taxon_match_input__copy_to__insert BEFORE INSERT ON taxon_match_input__copy_to FOR EACH ROW EXECUTE PROCEDURE taxon_match_input__copy_to__insert(); -- -- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: - -- ALTER TABLE ONLY batch ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: - -- ALTER TABLE ONLY batch_download_settings ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: - -- ALTER TABLE ONLY taxon_match ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: TNRS; Type: ACL; Schema: -; Owner: - -- REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC; REVOKE ALL ON SCHEMA "TNRS" FROM bien; GRANT ALL ON SCHEMA "TNRS" TO bien; GRANT USAGE ON SCHEMA "TNRS" TO bien_read; -- -- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE taxon_match FROM PUBLIC; REVOKE ALL ON TABLE taxon_match FROM bien; GRANT ALL ON TABLE taxon_match TO bien; GRANT SELECT ON TABLE taxon_match TO bien_read; -- -- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC; REVOKE ALL ON TABLE taxon_best_match FROM bien; GRANT ALL ON TABLE taxon_best_match TO bien; GRANT SELECT ON TABLE taxon_best_match TO bien_read; -- -- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC; REVOKE ALL ON TABLE "MatchedTaxon" FROM bien; GRANT ALL ON TABLE "MatchedTaxon" TO bien; GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read; -- -- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC; REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien; GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien; GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read; -- -- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC; REVOKE ALL ON TABLE taxon_match_input FROM bien; GRANT ALL ON TABLE taxon_match_input TO bien; GRANT SELECT ON TABLE taxon_match_input TO bien_read; -- -- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC; REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien; GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien; GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read; -- -- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: - -- REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC; REVOKE ALL ON TABLE taxon_scrub FROM bien; GRANT ALL ON TABLE taxon_scrub TO bien; GRANT SELECT ON TABLE taxon_scrub TO bien_read; -- -- PostgreSQL database dump complete --