1 |
10778
|
aaronmk
|
--
|
2 |
|
|
-- PostgreSQL database dump
|
3 |
|
|
--
|
4 |
10737
|
aaronmk
|
|
5 |
10778
|
aaronmk
|
SET statement_timeout = 0;
|
6 |
11708
|
aaronmk
|
SET lock_timeout = 0;
|
7 |
10778
|
aaronmk
|
SET client_encoding = 'UTF8';
|
8 |
|
|
SET standard_conforming_strings = on;
|
9 |
|
|
SET check_function_bodies = false;
|
10 |
|
|
SET client_min_messages = warning;
|
11 |
|
|
|
12 |
10737
|
aaronmk
|
--
|
13 |
10778
|
aaronmk
|
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
|
14 |
|
|
--
|
15 |
10737
|
aaronmk
|
|
16 |
10778
|
aaronmk
|
--CREATE SCHEMA "TNRS";
|
17 |
10725
|
aaronmk
|
|
18 |
|
|
|
19 |
11614
|
aaronmk
|
--
|
20 |
|
|
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
|
21 |
|
|
--
|
22 |
|
|
|
23 |
13575
|
aaronmk
|
COMMENT ON SCHEMA "TNRS" IS '
|
24 |
|
|
IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
|
25 |
11617
|
aaronmk
|
on vegbiendev:
|
26 |
|
|
# back up existing TNRS schema (in case of an accidental incorrect change):
|
27 |
11614
|
aaronmk
|
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
|
28 |
11616
|
aaronmk
|
$ svn up
|
29 |
|
|
$ svn di
|
30 |
|
|
# make the changes shown in the diff
|
31 |
|
|
## to change column types:
|
32 |
13861
|
aaronmk
|
SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[
|
33 |
11614
|
aaronmk
|
(''col'', ''new_type'')
|
34 |
11616
|
aaronmk
|
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
|
35 |
11617
|
aaronmk
|
$ rm=1 inputs/.TNRS/schema.sql.run
|
36 |
|
|
# repeat until `svn di` shows no diff
|
37 |
|
|
# back up new TNRS schema:
|
38 |
13575
|
aaronmk
|
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
|
39 |
|
|
';
|
40 |
11614
|
aaronmk
|
|
41 |
|
|
|
42 |
10778
|
aaronmk
|
SET search_path = "TNRS", pg_catalog;
|
43 |
|
|
|
44 |
|
|
--
|
45 |
|
|
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
46 |
|
|
--
|
47 |
|
|
|
48 |
|
|
CREATE FUNCTION batch__fill() RETURNS trigger
|
49 |
|
|
LANGUAGE plpgsql
|
50 |
|
|
AS $$
|
51 |
10728
|
aaronmk
|
BEGIN
|
52 |
|
|
new.id_by_time = new.time_submitted;
|
53 |
|
|
new.id = COALESCE(new.id, new.id_by_time);
|
54 |
|
|
RETURN new;
|
55 |
|
|
END;
|
56 |
10778
|
aaronmk
|
$$;
|
57 |
10728
|
aaronmk
|
|
58 |
|
|
|
59 |
|
|
--
|
60 |
10778
|
aaronmk
|
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
61 |
|
|
--
|
62 |
10728
|
aaronmk
|
|
63 |
10778
|
aaronmk
|
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
|
64 |
|
|
LANGUAGE sql STABLE STRICT
|
65 |
|
|
AS $_$
|
66 |
|
|
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
|
67 |
|
|
$_$;
|
68 |
10736
|
aaronmk
|
|
69 |
10778
|
aaronmk
|
|
70 |
10736
|
aaronmk
|
--
|
71 |
10778
|
aaronmk
|
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
72 |
|
|
--
|
73 |
10736
|
aaronmk
|
|
74 |
10778
|
aaronmk
|
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
|
75 |
|
|
LANGUAGE sql STABLE STRICT
|
76 |
|
|
AS $_$
|
77 |
|
|
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
|
78 |
|
|
$_$;
|
79 |
7844
|
aaronmk
|
|
80 |
9985
|
aaronmk
|
|
81 |
10778
|
aaronmk
|
--
|
82 |
11709
|
aaronmk
|
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
|
83 |
|
|
--
|
84 |
|
|
|
85 |
13503
|
aaronmk
|
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
|
86 |
11709
|
aaronmk
|
LANGUAGE sql IMMUTABLE
|
87 |
|
|
AS $_$
|
88 |
13503
|
aaronmk
|
/* from http://wiki.vegpath.org/2013-11-14_conference_call#taxonomic-fields:
|
89 |
|
|
"taxonomic_status should be accepted instead of synonym when an accepted name is
|
90 |
|
|
available (this is not always the case when a name is marked as a synonym)" */
|
91 |
11709
|
aaronmk
|
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
|
92 |
|
|
$_$;
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
--
|
96 |
13868
|
aaronmk
|
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
|
97 |
13866
|
aaronmk
|
--
|
98 |
|
|
|
99 |
13868
|
aaronmk
|
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
|
100 |
13866
|
aaronmk
|
LANGUAGE plpgsql
|
101 |
|
|
AS $$
|
102 |
|
|
BEGIN
|
103 |
13869
|
aaronmk
|
PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
|
104 |
13567
|
aaronmk
|
RETURN NULL;
|
105 |
|
|
END;
|
106 |
|
|
$$;
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
--
|
110 |
13868
|
aaronmk
|
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
111 |
13578
|
aaronmk
|
--
|
112 |
|
|
|
113 |
13868
|
aaronmk
|
CREATE FUNCTION taxon_match__fill() RETURNS trigger
|
114 |
13578
|
aaronmk
|
LANGUAGE plpgsql
|
115 |
|
|
AS $$
|
116 |
11643
|
aaronmk
|
BEGIN
|
117 |
13871
|
aaronmk
|
DECLARE
|
118 |
|
|
"Specific_epithet_is_plant" boolean :=
|
119 |
11628
|
aaronmk
|
(CASE
|
120 |
14111
|
aaronmk
|
WHEN new."*Infraspecific_epithet_matched" IS NOT NULL
|
121 |
|
|
OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
|
122 |
|
|
OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
|
123 |
13871
|
aaronmk
|
THEN true
|
124 |
|
|
ELSE NULL -- ambiguous
|
125 |
|
|
END);
|
126 |
14111
|
aaronmk
|
never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
|
127 |
13871
|
aaronmk
|
-- author disambiguates
|
128 |
|
|
family_is_homonym boolean = NOT never_homonym
|
129 |
14111
|
aaronmk
|
AND "TNRS".family_is_homonym(new."*Family_matched");
|
130 |
13871
|
aaronmk
|
genus_is_homonym boolean = NOT never_homonym
|
131 |
14111
|
aaronmk
|
AND "TNRS".genus_is_homonym(new."*Genus_matched");
|
132 |
13871
|
aaronmk
|
BEGIN
|
133 |
|
|
/* exclude homonyms because these are not valid matches (TNRS provides a
|
134 |
|
|
name, but the name is not meaningful because it is not unambiguous) */
|
135 |
14111
|
aaronmk
|
new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
|
136 |
13871
|
aaronmk
|
AND COALESCE(CASE
|
137 |
14111
|
aaronmk
|
WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
|
138 |
13871
|
aaronmk
|
THEN true
|
139 |
|
|
ELSE -- consider genus
|
140 |
11628
|
aaronmk
|
(CASE
|
141 |
14111
|
aaronmk
|
WHEN new."*Genus_score" = 1 -- exact match
|
142 |
13871
|
aaronmk
|
THEN
|
143 |
|
|
(CASE
|
144 |
|
|
WHEN NOT genus_is_homonym THEN true
|
145 |
|
|
ELSE "Specific_epithet_is_plant"
|
146 |
|
|
END)
|
147 |
14111
|
aaronmk
|
WHEN new."*Genus_score" >= 0.85 -- fuzzy match
|
148 |
13871
|
aaronmk
|
THEN "Specific_epithet_is_plant"
|
149 |
|
|
ELSE NULL -- ambiguous
|
150 |
11628
|
aaronmk
|
END)
|
151 |
13871
|
aaronmk
|
END, false);
|
152 |
|
|
END;
|
153 |
11628
|
aaronmk
|
|
154 |
13871
|
aaronmk
|
DECLARE
|
155 |
|
|
matched_taxon_name_with_author text = NULLIF(concat_ws(' '
|
156 |
14111
|
aaronmk
|
, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
|
157 |
|
|
new."*Name_matched")
|
158 |
|
|
, NULLIF(new."*Name_matched", 'No suitable matches found.')
|
159 |
|
|
, new."*Name_matched_author"
|
160 |
13871
|
aaronmk
|
), '');
|
161 |
|
|
accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
|
162 |
14111
|
aaronmk
|
, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
|
163 |
|
|
new."*Accepted_name")
|
164 |
|
|
, new."*Accepted_name"
|
165 |
|
|
, new."*Accepted_name_author"
|
166 |
13871
|
aaronmk
|
), '');
|
167 |
|
|
BEGIN
|
168 |
|
|
new.scrubbed_unique_taxon_name = COALESCE(
|
169 |
|
|
accepted_taxon_name_with_author, matched_taxon_name_with_author);
|
170 |
|
|
END;
|
171 |
|
|
|
172 |
11628
|
aaronmk
|
RETURN new;
|
173 |
7134
|
aaronmk
|
END;
|
174 |
10778
|
aaronmk
|
$$;
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
--
|
178 |
13868
|
aaronmk
|
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
|
179 |
10778
|
aaronmk
|
--
|
180 |
|
|
|
181 |
13868
|
aaronmk
|
COMMENT ON FUNCTION taxon_match__fill() IS '
|
182 |
13575
|
aaronmk
|
IMPORTANT: when changing this function, you must regenerate the derived cols:
|
183 |
13861
|
aaronmk
|
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
|
184 |
11715
|
aaronmk
|
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
|
185 |
13861
|
aaronmk
|
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
|
186 |
13575
|
aaronmk
|
runtime: 1.5 min ("92633 ms")
|
187 |
|
|
';
|
188 |
7134
|
aaronmk
|
|
189 |
7251
|
aaronmk
|
|
190 |
13631
|
aaronmk
|
--
|
191 |
14122
|
aaronmk
|
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
|
192 |
|
|
--
|
193 |
|
|
|
194 |
|
|
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
|
195 |
|
|
LANGUAGE plpgsql
|
196 |
|
|
AS $$
|
197 |
|
|
BEGIN
|
198 |
|
|
new."__accepted_{genus,specific_epithet}" = (SELECT
|
199 |
14150
|
aaronmk
|
regexp_split_to_array("*Accepted_name_species", ' '::text)
|
200 |
14122
|
aaronmk
|
FROM (SELECT new.*) new);
|
201 |
|
|
|
202 |
14257
|
aaronmk
|
new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT
|
203 |
|
|
"__accepted_{genus,specific_epithet}"[1]
|
204 |
|
|
FROM (SELECT new.*) new);
|
205 |
|
|
|
206 |
|
|
new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT
|
207 |
|
|
"__accepted_{genus,specific_epithet}"[2]
|
208 |
|
|
FROM (SELECT new.*) new);
|
209 |
|
|
|
210 |
14264
|
aaronmk
|
new.__accepted_infraspecific_label = (SELECT
|
211 |
|
|
ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)
|
212 |
|
|
FROM (SELECT new.*) new);
|
213 |
|
|
|
214 |
14265
|
aaronmk
|
new."__accepted_infraspecific_{rank,epithet}" = (SELECT
|
215 |
|
|
regexp_split_to_array(__accepted_infraspecific_label, ' '::text)
|
216 |
|
|
FROM (SELECT new.*) new);
|
217 |
|
|
|
218 |
14266
|
aaronmk
|
new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT
|
219 |
|
|
"__accepted_infraspecific_{rank,epithet}"[1]
|
220 |
|
|
FROM (SELECT new.*) new);
|
221 |
|
|
|
222 |
|
|
new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT
|
223 |
|
|
"__accepted_infraspecific_{rank,epithet}"[2]
|
224 |
|
|
FROM (SELECT new.*) new);
|
225 |
|
|
|
226 |
14122
|
aaronmk
|
RETURN new;
|
227 |
|
|
END;
|
228 |
|
|
$$;
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
--
|
232 |
14254
|
aaronmk
|
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
|
233 |
|
|
--
|
234 |
|
|
|
235 |
|
|
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
|
236 |
|
|
autogenerated, do not edit
|
237 |
|
|
|
238 |
|
|
to regenerate:
|
239 |
|
|
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
|
240 |
|
|
';
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
--
|
244 |
13868
|
aaronmk
|
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
|
245 |
|
|
--
|
246 |
|
|
|
247 |
|
|
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
|
248 |
|
|
LANGUAGE plpgsql
|
249 |
|
|
AS $$
|
250 |
|
|
BEGIN
|
251 |
|
|
IF new.match_num IS NULL THEN
|
252 |
13869
|
aaronmk
|
new.match_num = "TNRS".taxon_match__match_num__next();
|
253 |
13868
|
aaronmk
|
END IF;
|
254 |
|
|
RETURN new;
|
255 |
|
|
END;
|
256 |
|
|
$$;
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
--
|
260 |
13869
|
aaronmk
|
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
|
261 |
|
|
--
|
262 |
|
|
|
263 |
|
|
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
|
264 |
|
|
LANGUAGE sql
|
265 |
|
|
AS $$
|
266 |
|
|
SELECT nextval('pg_temp.taxon_match__match_num__seq');
|
267 |
|
|
$$;
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
--
|
271 |
13868
|
aaronmk
|
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
|
272 |
|
|
--
|
273 |
|
|
|
274 |
|
|
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
|
275 |
|
|
LANGUAGE plpgsql
|
276 |
|
|
AS $$
|
277 |
|
|
BEGIN
|
278 |
|
|
INSERT INTO "TNRS".taxon_match_input SELECT new.*;
|
279 |
|
|
RETURN NULL;
|
280 |
|
|
END;
|
281 |
|
|
$$;
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
--
|
285 |
|
|
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
|
286 |
|
|
--
|
287 |
|
|
|
288 |
|
|
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
|
289 |
|
|
LANGUAGE sql IMMUTABLE
|
290 |
|
|
AS $_$
|
291 |
|
|
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
|
292 |
|
|
$_$;
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
--
|
296 |
13631
|
aaronmk
|
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
|
297 |
|
|
--
|
298 |
|
|
|
299 |
|
|
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
|
300 |
|
|
LANGUAGE sql IMMUTABLE
|
301 |
|
|
AS $$
|
302 |
|
|
SELECT ARRAY[
|
303 |
13686
|
aaronmk
|
]::text[]
|
304 |
13631
|
aaronmk
|
$$;
|
305 |
|
|
|
306 |
|
|
|
307 |
10778
|
aaronmk
|
SET default_tablespace = '';
|
308 |
|
|
|
309 |
|
|
SET default_with_oids = false;
|
310 |
|
|
|
311 |
10728
|
aaronmk
|
--
|
312 |
13861
|
aaronmk
|
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
313 |
10778
|
aaronmk
|
--
|
314 |
7251
|
aaronmk
|
|
315 |
13861
|
aaronmk
|
CREATE TABLE taxon_match (
|
316 |
10778
|
aaronmk
|
batch text DEFAULT now() NOT NULL,
|
317 |
13580
|
aaronmk
|
match_num integer NOT NULL,
|
318 |
14111
|
aaronmk
|
"*Name_number" integer NOT NULL,
|
319 |
|
|
"*Name_submitted" text NOT NULL,
|
320 |
|
|
"*Overall_score" double precision,
|
321 |
|
|
"*Name_matched" text,
|
322 |
|
|
"*Name_matched_rank" text,
|
323 |
|
|
"*Name_score" double precision,
|
324 |
|
|
"*Name_matched_author" text,
|
325 |
|
|
"*Name_matched_url" text,
|
326 |
|
|
"*Author_matched" text,
|
327 |
|
|
"*Author_score" double precision,
|
328 |
|
|
"*Family_matched" text,
|
329 |
|
|
"*Family_score" double precision,
|
330 |
|
|
"*Name_matched_accepted_family" text,
|
331 |
|
|
"*Genus_matched" text,
|
332 |
|
|
"*Genus_score" double precision,
|
333 |
|
|
"*Specific_epithet_matched" text,
|
334 |
|
|
"*Specific_epithet_score" double precision,
|
335 |
|
|
"*Infraspecific_rank" text,
|
336 |
|
|
"*Infraspecific_epithet_matched" text,
|
337 |
|
|
"*Infraspecific_epithet_score" double precision,
|
338 |
|
|
"*Infraspecific_rank_2" text,
|
339 |
|
|
"*Infraspecific_epithet_2_matched" text,
|
340 |
|
|
"*Infraspecific_epithet_2_score" double precision,
|
341 |
|
|
"*Annotations" text,
|
342 |
|
|
"*Unmatched_terms" text,
|
343 |
|
|
"*Taxonomic_status" text,
|
344 |
|
|
"*Accepted_name" text,
|
345 |
|
|
"*Accepted_name_author" text,
|
346 |
|
|
"*Accepted_name_rank" text,
|
347 |
|
|
"*Accepted_name_url" text,
|
348 |
|
|
"*Accepted_name_species" text,
|
349 |
|
|
"*Accepted_name_family" text,
|
350 |
|
|
"*Selected" text,
|
351 |
|
|
"*Source" text,
|
352 |
|
|
"*Warnings" text,
|
353 |
|
|
"*Accepted_name_lsid" text,
|
354 |
11628
|
aaronmk
|
is_valid_match boolean NOT NULL,
|
355 |
14122
|
aaronmk
|
scrubbed_unique_taxon_name text,
|
356 |
|
|
"__accepted_{genus,specific_epithet}" text[],
|
357 |
14257
|
aaronmk
|
"[accepted_]genus__@DwC__@vegpath.org" text,
|
358 |
|
|
"[accepted_]specificEpithet__@DwC__@vegpath.org" text,
|
359 |
14264
|
aaronmk
|
__accepted_infraspecific_label text,
|
360 |
14265
|
aaronmk
|
"__accepted_infraspecific_{rank,epithet}" text[],
|
361 |
14266
|
aaronmk
|
"[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
|
362 |
|
|
"[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
|
363 |
|
|
CONSTRAINT "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[1]))),
|
364 |
14257
|
aaronmk
|
CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[1]))),
|
365 |
14266
|
aaronmk
|
CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
|
366 |
14257
|
aaronmk
|
CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[2]))),
|
367 |
14264
|
aaronmk
|
CONSTRAINT __accepted_infraspecific_label CHECK ((NOT (__accepted_infraspecific_label IS DISTINCT FROM ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)))),
|
368 |
14265
|
aaronmk
|
CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM regexp_split_to_array(__accepted_infraspecific_label, ' '::text)))),
|
369 |
14122
|
aaronmk
|
CONSTRAINT "__accepted_{genus,specific_epithet}" CHECK ((NOT ("__accepted_{genus,specific_epithet}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name_species", ' '::text))))
|
370 |
10778
|
aaronmk
|
);
|
371 |
7823
|
aaronmk
|
|
372 |
9759
|
aaronmk
|
|
373 |
10778
|
aaronmk
|
--
|
374 |
13861
|
aaronmk
|
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
|
375 |
10778
|
aaronmk
|
--
|
376 |
7823
|
aaronmk
|
|
377 |
13861
|
aaronmk
|
COMMENT ON TABLE taxon_match IS '
|
378 |
14161
|
aaronmk
|
whenever columns are renamed:
|
379 |
|
|
SELECT util.derived_cols_sync(''"TNRS".taxon_match'');
|
380 |
|
|
|
381 |
13577
|
aaronmk
|
to remove columns or add columns at the end:
|
382 |
|
|
$ rm=1 inputs/.TNRS/data.sql.run
|
383 |
|
|
$ make schemas/remake
|
384 |
|
|
|
385 |
|
|
to add columns in the middle:
|
386 |
|
|
make the changes in inputs/.TNRS/schema.sql
|
387 |
|
|
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
|
388 |
|
|
$ make schemas/remake
|
389 |
13582
|
aaronmk
|
|
390 |
|
|
to populate a new column:
|
391 |
13868
|
aaronmk
|
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
|
392 |
13861
|
aaronmk
|
UPDATE "TNRS".taxon_match SET "col" = value;
|
393 |
13582
|
aaronmk
|
-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
|
394 |
14132
|
aaronmk
|
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
|
395 |
13868
|
aaronmk
|
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
|
396 |
13861
|
aaronmk
|
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
|
397 |
13584
|
aaronmk
|
|
398 |
|
|
to add a constraint: runtime: 3 min ("173620 ms")
|
399 |
13575
|
aaronmk
|
';
|
400 |
10778
|
aaronmk
|
|
401 |
|
|
|
402 |
|
|
--
|
403 |
14254
|
aaronmk
|
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
404 |
|
|
--
|
405 |
|
|
|
406 |
|
|
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
|
407 |
|
|
derived column; = regexp_split_to_array("*Accepted_name_species", '' ''::text)
|
408 |
|
|
|
409 |
|
|
to modify:
|
410 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet}'')::util.col, $$regexp_split_to_array("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
|
411 |
14258
|
aaronmk
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
412 |
14254
|
aaronmk
|
';
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
--
|
416 |
14257
|
aaronmk
|
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
417 |
|
|
--
|
418 |
|
|
|
419 |
|
|
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
|
420 |
|
|
derived column; = "__accepted_{genus,specific_epithet}"[1]
|
421 |
|
|
|
422 |
|
|
to modify:
|
423 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[1]$$)::util.derived_col_def);
|
424 |
14258
|
aaronmk
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
425 |
14257
|
aaronmk
|
';
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
--
|
429 |
|
|
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
430 |
|
|
--
|
431 |
|
|
|
432 |
|
|
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
|
433 |
|
|
derived column; = "__accepted_{genus,specific_epithet}"[2]
|
434 |
|
|
|
435 |
|
|
to modify:
|
436 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[2]$$)::util.derived_col_def);
|
437 |
14258
|
aaronmk
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
438 |
14257
|
aaronmk
|
';
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
--
|
442 |
14264
|
aaronmk
|
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
|
443 |
|
|
--
|
444 |
|
|
|
445 |
|
|
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
|
446 |
|
|
derived column; = ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''), '' '')
|
447 |
|
|
|
448 |
|
|
to modify:
|
449 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''), '' '')$$)::util.derived_col_def);
|
450 |
|
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
451 |
|
|
';
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
--
|
455 |
14265
|
aaronmk
|
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
|
456 |
|
|
--
|
457 |
|
|
|
458 |
|
|
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
|
459 |
|
|
derived column; = regexp_split_to_array("__accepted_infraspecific_label", '' ''::text)
|
460 |
|
|
|
461 |
|
|
to modify:
|
462 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$regexp_split_to_array("__accepted_infraspecific_label", '' ''::text)$$)::util.derived_col_def);
|
463 |
|
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
464 |
|
|
';
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
--
|
468 |
14266
|
aaronmk
|
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
469 |
|
|
--
|
470 |
|
|
|
471 |
|
|
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
|
472 |
|
|
derived column; = "__accepted_infraspecific_{rank,epithet}"[1]
|
473 |
|
|
|
474 |
|
|
to modify:
|
475 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[1]$$)::util.derived_col_def);
|
476 |
|
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
477 |
|
|
';
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
--
|
481 |
|
|
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
|
482 |
|
|
--
|
483 |
|
|
|
484 |
|
|
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
|
485 |
|
|
derived column; = "__accepted_infraspecific_{rank,epithet}"[2]
|
486 |
|
|
|
487 |
|
|
to modify:
|
488 |
|
|
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
|
489 |
|
|
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
|
490 |
|
|
';
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
--
|
494 |
13878
|
aaronmk
|
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
|
495 |
|
|
--
|
496 |
|
|
|
497 |
|
|
CREATE VIEW taxon_best_match AS
|
498 |
|
|
SELECT taxon_match.batch,
|
499 |
|
|
taxon_match.match_num,
|
500 |
14111
|
aaronmk
|
taxon_match."*Name_number",
|
501 |
|
|
taxon_match."*Name_submitted",
|
502 |
|
|
taxon_match."*Overall_score",
|
503 |
|
|
taxon_match."*Name_matched",
|
504 |
|
|
taxon_match."*Name_matched_rank",
|
505 |
|
|
taxon_match."*Name_score",
|
506 |
|
|
taxon_match."*Name_matched_author",
|
507 |
|
|
taxon_match."*Name_matched_url",
|
508 |
|
|
taxon_match."*Author_matched",
|
509 |
|
|
taxon_match."*Author_score",
|
510 |
|
|
taxon_match."*Family_matched",
|
511 |
|
|
taxon_match."*Family_score",
|
512 |
|
|
taxon_match."*Name_matched_accepted_family",
|
513 |
|
|
taxon_match."*Genus_matched",
|
514 |
|
|
taxon_match."*Genus_score",
|
515 |
|
|
taxon_match."*Specific_epithet_matched",
|
516 |
|
|
taxon_match."*Specific_epithet_score",
|
517 |
|
|
taxon_match."*Infraspecific_rank",
|
518 |
|
|
taxon_match."*Infraspecific_epithet_matched",
|
519 |
|
|
taxon_match."*Infraspecific_epithet_score",
|
520 |
|
|
taxon_match."*Infraspecific_rank_2",
|
521 |
|
|
taxon_match."*Infraspecific_epithet_2_matched",
|
522 |
|
|
taxon_match."*Infraspecific_epithet_2_score",
|
523 |
|
|
taxon_match."*Annotations",
|
524 |
|
|
taxon_match."*Unmatched_terms",
|
525 |
|
|
taxon_match."*Taxonomic_status",
|
526 |
|
|
taxon_match."*Accepted_name",
|
527 |
|
|
taxon_match."*Accepted_name_author",
|
528 |
|
|
taxon_match."*Accepted_name_rank",
|
529 |
|
|
taxon_match."*Accepted_name_url",
|
530 |
|
|
taxon_match."*Accepted_name_species",
|
531 |
|
|
taxon_match."*Accepted_name_family",
|
532 |
|
|
taxon_match."*Selected",
|
533 |
|
|
taxon_match."*Source",
|
534 |
|
|
taxon_match."*Warnings",
|
535 |
|
|
taxon_match."*Accepted_name_lsid",
|
536 |
13878
|
aaronmk
|
taxon_match.is_valid_match,
|
537 |
|
|
taxon_match.scrubbed_unique_taxon_name
|
538 |
|
|
FROM taxon_match
|
539 |
14111
|
aaronmk
|
WHERE (taxon_match."*Selected" = 'true'::text);
|
540 |
13878
|
aaronmk
|
|
541 |
|
|
|
542 |
|
|
--
|
543 |
|
|
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
|
544 |
|
|
--
|
545 |
|
|
|
546 |
|
|
COMMENT ON VIEW taxon_best_match IS '
|
547 |
|
|
to modify:
|
548 |
|
|
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
|
549 |
|
|
SELECT __
|
550 |
|
|
$$);
|
551 |
|
|
';
|
552 |
|
|
|
553 |
|
|
|
554 |
|
|
--
|
555 |
10778
|
aaronmk
|
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
556 |
|
|
--
|
557 |
|
|
|
558 |
|
|
CREATE VIEW "MatchedTaxon" AS
|
559 |
14110
|
aaronmk
|
SELECT taxon_best_match.batch,
|
560 |
|
|
taxon_best_match.match_num,
|
561 |
14111
|
aaronmk
|
taxon_best_match."*Name_number",
|
562 |
|
|
taxon_best_match."*Name_submitted",
|
563 |
|
|
taxon_best_match."*Overall_score",
|
564 |
|
|
taxon_best_match."*Name_matched",
|
565 |
|
|
taxon_best_match."*Name_matched_rank",
|
566 |
|
|
taxon_best_match."*Name_score",
|
567 |
|
|
taxon_best_match."*Name_matched_author",
|
568 |
|
|
taxon_best_match."*Name_matched_url",
|
569 |
|
|
taxon_best_match."*Author_matched",
|
570 |
|
|
taxon_best_match."*Author_score",
|
571 |
|
|
taxon_best_match."*Family_matched",
|
572 |
|
|
taxon_best_match."*Family_score",
|
573 |
|
|
taxon_best_match."*Name_matched_accepted_family",
|
574 |
|
|
taxon_best_match."*Genus_matched",
|
575 |
|
|
taxon_best_match."*Genus_score",
|
576 |
|
|
taxon_best_match."*Specific_epithet_matched",
|
577 |
|
|
taxon_best_match."*Specific_epithet_score",
|
578 |
|
|
taxon_best_match."*Infraspecific_rank",
|
579 |
|
|
taxon_best_match."*Infraspecific_epithet_matched",
|
580 |
|
|
taxon_best_match."*Infraspecific_epithet_score",
|
581 |
|
|
taxon_best_match."*Infraspecific_rank_2",
|
582 |
|
|
taxon_best_match."*Infraspecific_epithet_2_matched",
|
583 |
|
|
taxon_best_match."*Infraspecific_epithet_2_score",
|
584 |
|
|
taxon_best_match."*Annotations",
|
585 |
|
|
taxon_best_match."*Unmatched_terms",
|
586 |
|
|
taxon_best_match."*Taxonomic_status",
|
587 |
|
|
taxon_best_match."*Accepted_name",
|
588 |
|
|
taxon_best_match."*Accepted_name_author",
|
589 |
|
|
taxon_best_match."*Accepted_name_rank",
|
590 |
|
|
taxon_best_match."*Accepted_name_url",
|
591 |
|
|
taxon_best_match."*Accepted_name_species",
|
592 |
|
|
taxon_best_match."*Accepted_name_family",
|
593 |
|
|
taxon_best_match."*Selected",
|
594 |
|
|
taxon_best_match."*Source",
|
595 |
|
|
taxon_best_match."*Warnings",
|
596 |
|
|
taxon_best_match."*Accepted_name_lsid",
|
597 |
14110
|
aaronmk
|
taxon_best_match.is_valid_match,
|
598 |
|
|
taxon_best_match.scrubbed_unique_taxon_name,
|
599 |
14111
|
aaronmk
|
map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
|
600 |
13498
|
aaronmk
|
CASE
|
601 |
14111
|
aaronmk
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
|
602 |
|
|
WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
|
603 |
|
|
ELSE taxon_best_match."*Accepted_name_species"
|
604 |
13498
|
aaronmk
|
END AS accepted_morphospecies_binomial
|
605 |
14110
|
aaronmk
|
FROM taxon_best_match;
|
606 |
10778
|
aaronmk
|
|
607 |
|
|
|
608 |
|
|
--
|
609 |
13498
|
aaronmk
|
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
610 |
|
|
--
|
611 |
|
|
|
612 |
|
|
COMMENT ON VIEW "MatchedTaxon" IS '
|
613 |
13501
|
aaronmk
|
to modify:
|
614 |
13845
|
aaronmk
|
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
|
615 |
13647
|
aaronmk
|
SELECT __
|
616 |
13501
|
aaronmk
|
$$);
|
617 |
13498
|
aaronmk
|
';
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
--
|
621 |
10778
|
aaronmk
|
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
|
622 |
|
|
--
|
623 |
|
|
|
624 |
|
|
CREATE VIEW "ValidMatchedTaxon" AS
|
625 |
14108
|
aaronmk
|
SELECT "MatchedTaxon".batch,
|
626 |
14105
|
aaronmk
|
"MatchedTaxon".match_num,
|
627 |
14111
|
aaronmk
|
"MatchedTaxon"."*Name_number",
|
628 |
|
|
"MatchedTaxon"."*Name_submitted",
|
629 |
|
|
"MatchedTaxon"."*Overall_score",
|
630 |
|
|
"MatchedTaxon"."*Name_matched",
|
631 |
|
|
"MatchedTaxon"."*Name_matched_rank",
|
632 |
|
|
"MatchedTaxon"."*Name_score",
|
633 |
|
|
"MatchedTaxon"."*Name_matched_author",
|
634 |
|
|
"MatchedTaxon"."*Name_matched_url",
|
635 |
|
|
"MatchedTaxon"."*Author_matched",
|
636 |
|
|
"MatchedTaxon"."*Author_score",
|
637 |
|
|
"MatchedTaxon"."*Family_matched",
|
638 |
|
|
"MatchedTaxon"."*Family_score",
|
639 |
|
|
"MatchedTaxon"."*Name_matched_accepted_family",
|
640 |
|
|
"MatchedTaxon"."*Genus_matched",
|
641 |
|
|
"MatchedTaxon"."*Genus_score",
|
642 |
|
|
"MatchedTaxon"."*Specific_epithet_matched",
|
643 |
|
|
"MatchedTaxon"."*Specific_epithet_score",
|
644 |
|
|
"MatchedTaxon"."*Infraspecific_rank",
|
645 |
|
|
"MatchedTaxon"."*Infraspecific_epithet_matched",
|
646 |
|
|
"MatchedTaxon"."*Infraspecific_epithet_score",
|
647 |
|
|
"MatchedTaxon"."*Infraspecific_rank_2",
|
648 |
|
|
"MatchedTaxon"."*Infraspecific_epithet_2_matched",
|
649 |
|
|
"MatchedTaxon"."*Infraspecific_epithet_2_score",
|
650 |
|
|
"MatchedTaxon"."*Annotations",
|
651 |
|
|
"MatchedTaxon"."*Unmatched_terms",
|
652 |
|
|
"MatchedTaxon"."*Taxonomic_status",
|
653 |
|
|
"MatchedTaxon"."*Accepted_name",
|
654 |
|
|
"MatchedTaxon"."*Accepted_name_author",
|
655 |
|
|
"MatchedTaxon"."*Accepted_name_rank",
|
656 |
|
|
"MatchedTaxon"."*Accepted_name_url",
|
657 |
|
|
"MatchedTaxon"."*Accepted_name_species",
|
658 |
|
|
"MatchedTaxon"."*Accepted_name_family",
|
659 |
|
|
"MatchedTaxon"."*Selected",
|
660 |
|
|
"MatchedTaxon"."*Source",
|
661 |
|
|
"MatchedTaxon"."*Warnings",
|
662 |
|
|
"MatchedTaxon"."*Accepted_name_lsid",
|
663 |
14108
|
aaronmk
|
"MatchedTaxon".is_valid_match,
|
664 |
13800
|
aaronmk
|
"MatchedTaxon".scrubbed_unique_taxon_name,
|
665 |
14103
|
aaronmk
|
"MatchedTaxon"."taxonomicStatus",
|
666 |
13498
|
aaronmk
|
"MatchedTaxon".accepted_morphospecies_binomial
|
667 |
11708
|
aaronmk
|
FROM "MatchedTaxon"
|
668 |
14108
|
aaronmk
|
WHERE "MatchedTaxon".is_valid_match;
|
669 |
10778
|
aaronmk
|
|
670 |
|
|
|
671 |
|
|
--
|
672 |
|
|
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
|
673 |
|
|
--
|
674 |
|
|
|
675 |
13443
|
aaronmk
|
COMMENT ON VIEW "ValidMatchedTaxon" IS '
|
676 |
|
|
to update, use * as the column list
|
677 |
|
|
';
|
678 |
10778
|
aaronmk
|
|
679 |
|
|
|
680 |
|
|
--
|
681 |
|
|
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
682 |
|
|
--
|
683 |
|
|
|
684 |
|
|
CREATE TABLE batch (
|
685 |
|
|
id text NOT NULL,
|
686 |
|
|
id_by_time text,
|
687 |
|
|
time_submitted timestamp with time zone DEFAULT now(),
|
688 |
|
|
client_version text
|
689 |
|
|
);
|
690 |
|
|
|
691 |
|
|
|
692 |
|
|
--
|
693 |
|
|
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
694 |
|
|
--
|
695 |
|
|
|
696 |
|
|
CREATE TABLE batch_download_settings (
|
697 |
|
|
id text NOT NULL,
|
698 |
|
|
"E-mail" text,
|
699 |
|
|
"Id" text,
|
700 |
|
|
"Job type" text,
|
701 |
|
|
"Contains Id" boolean,
|
702 |
|
|
"Start time" text,
|
703 |
|
|
"Finish time" text,
|
704 |
|
|
"TNRS version" text,
|
705 |
|
|
"Sources selected" text,
|
706 |
|
|
"Match threshold" double precision,
|
707 |
|
|
"Classification" text,
|
708 |
|
|
"Allow partial matches?" boolean,
|
709 |
|
|
"Sort by source" boolean,
|
710 |
|
|
"Constrain by higher taxonomy" boolean
|
711 |
|
|
);
|
712 |
|
|
|
713 |
|
|
|
714 |
|
|
--
|
715 |
|
|
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
|
716 |
|
|
--
|
717 |
|
|
|
718 |
13575
|
aaronmk
|
COMMENT ON TABLE batch_download_settings IS '
|
719 |
|
|
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
|
720 |
|
|
';
|
721 |
10778
|
aaronmk
|
|
722 |
|
|
|
723 |
|
|
--
|
724 |
|
|
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
725 |
|
|
--
|
726 |
|
|
|
727 |
|
|
CREATE TABLE client_version (
|
728 |
|
|
id text NOT NULL,
|
729 |
|
|
global_rev integer NOT NULL,
|
730 |
|
|
"/lib/tnrs.py rev" integer,
|
731 |
|
|
"/bin/tnrs_db rev" integer
|
732 |
|
|
);
|
733 |
|
|
|
734 |
|
|
|
735 |
|
|
--
|
736 |
|
|
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
|
737 |
|
|
--
|
738 |
|
|
|
739 |
13575
|
aaronmk
|
COMMENT ON TABLE client_version IS '
|
740 |
|
|
contains svn revisions
|
741 |
|
|
';
|
742 |
10778
|
aaronmk
|
|
743 |
|
|
|
744 |
|
|
--
|
745 |
|
|
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
|
746 |
|
|
--
|
747 |
|
|
|
748 |
13575
|
aaronmk
|
COMMENT ON COLUMN client_version.global_rev IS '
|
749 |
|
|
from `svn info .` > Last Changed Rev
|
750 |
|
|
';
|
751 |
10778
|
aaronmk
|
|
752 |
|
|
|
753 |
|
|
--
|
754 |
|
|
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
755 |
|
|
--
|
756 |
|
|
|
757 |
13575
|
aaronmk
|
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
|
758 |
|
|
from `svn info lib/tnrs.py` > Last Changed Rev
|
759 |
|
|
';
|
760 |
10778
|
aaronmk
|
|
761 |
|
|
|
762 |
|
|
--
|
763 |
|
|
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
|
764 |
|
|
--
|
765 |
|
|
|
766 |
13575
|
aaronmk
|
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
|
767 |
|
|
from `svn info bin/tnrs_db` > Last Changed Rev
|
768 |
|
|
';
|
769 |
10778
|
aaronmk
|
|
770 |
|
|
|
771 |
|
|
--
|
772 |
13866
|
aaronmk
|
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
|
773 |
|
|
--
|
774 |
|
|
|
775 |
|
|
CREATE VIEW taxon_match_input AS
|
776 |
14111
|
aaronmk
|
SELECT taxon_match."*Name_number" AS "Name_number",
|
777 |
|
|
taxon_match."*Name_submitted" AS "Name_submitted",
|
778 |
|
|
taxon_match."*Overall_score" AS "Overall_score",
|
779 |
|
|
taxon_match."*Name_matched" AS "Name_matched",
|
780 |
|
|
taxon_match."*Name_matched_rank" AS "Name_matched_rank",
|
781 |
|
|
taxon_match."*Name_score" AS "Name_score",
|
782 |
|
|
taxon_match."*Name_matched_author" AS "Name_matched_author",
|
783 |
|
|
taxon_match."*Name_matched_url" AS "Name_matched_url",
|
784 |
|
|
taxon_match."*Author_matched" AS "Author_matched",
|
785 |
|
|
taxon_match."*Author_score" AS "Author_score",
|
786 |
|
|
taxon_match."*Family_matched" AS "Family_matched",
|
787 |
|
|
taxon_match."*Family_score" AS "Family_score",
|
788 |
|
|
taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
|
789 |
|
|
taxon_match."*Genus_matched" AS "Genus_matched",
|
790 |
|
|
taxon_match."*Genus_score" AS "Genus_score",
|
791 |
|
|
taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
|
792 |
|
|
taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
|
793 |
|
|
taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
|
794 |
|
|
taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
|
795 |
|
|
taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
|
796 |
|
|
taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
|
797 |
|
|
taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
|
798 |
|
|
taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
|
799 |
|
|
taxon_match."*Annotations" AS "Annotations",
|
800 |
|
|
taxon_match."*Unmatched_terms" AS "Unmatched_terms",
|
801 |
|
|
taxon_match."*Taxonomic_status" AS "Taxonomic_status",
|
802 |
|
|
taxon_match."*Accepted_name" AS "Accepted_name",
|
803 |
|
|
taxon_match."*Accepted_name_author" AS "Accepted_name_author",
|
804 |
|
|
taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
|
805 |
|
|
taxon_match."*Accepted_name_url" AS "Accepted_name_url",
|
806 |
|
|
taxon_match."*Accepted_name_species" AS "Accepted_name_species",
|
807 |
|
|
taxon_match."*Accepted_name_family" AS "Accepted_name_family",
|
808 |
|
|
taxon_match."*Selected" AS "Selected",
|
809 |
|
|
taxon_match."*Source" AS "Source",
|
810 |
|
|
taxon_match."*Warnings" AS "Warnings",
|
811 |
|
|
taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
|
812 |
13866
|
aaronmk
|
FROM taxon_match;
|
813 |
|
|
|
814 |
|
|
|
815 |
|
|
--
|
816 |
|
|
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
|
817 |
|
|
--
|
818 |
|
|
|
819 |
|
|
CREATE TABLE taxon_match_input__copy_to (
|
820 |
|
|
"Name_number" integer,
|
821 |
|
|
"Name_submitted" text,
|
822 |
|
|
"Overall_score" double precision,
|
823 |
|
|
"Name_matched" text,
|
824 |
|
|
"Name_matched_rank" text,
|
825 |
|
|
"Name_score" double precision,
|
826 |
|
|
"Name_matched_author" text,
|
827 |
|
|
"Name_matched_url" text,
|
828 |
|
|
"Author_matched" text,
|
829 |
|
|
"Author_score" double precision,
|
830 |
|
|
"Family_matched" text,
|
831 |
|
|
"Family_score" double precision,
|
832 |
|
|
"Name_matched_accepted_family" text,
|
833 |
|
|
"Genus_matched" text,
|
834 |
|
|
"Genus_score" double precision,
|
835 |
|
|
"Specific_epithet_matched" text,
|
836 |
|
|
"Specific_epithet_score" double precision,
|
837 |
|
|
"Infraspecific_rank" text,
|
838 |
|
|
"Infraspecific_epithet_matched" text,
|
839 |
|
|
"Infraspecific_epithet_score" double precision,
|
840 |
|
|
"Infraspecific_rank_2" text,
|
841 |
|
|
"Infraspecific_epithet_2_matched" text,
|
842 |
|
|
"Infraspecific_epithet_2_score" double precision,
|
843 |
|
|
"Annotations" text,
|
844 |
|
|
"Unmatched_terms" text,
|
845 |
|
|
"Taxonomic_status" text,
|
846 |
|
|
"Accepted_name" text,
|
847 |
|
|
"Accepted_name_author" text,
|
848 |
|
|
"Accepted_name_rank" text,
|
849 |
|
|
"Accepted_name_url" text,
|
850 |
|
|
"Accepted_name_species" text,
|
851 |
|
|
"Accepted_name_family" text,
|
852 |
|
|
"Selected" text,
|
853 |
|
|
"Source" text,
|
854 |
|
|
"Warnings" text,
|
855 |
|
|
"Accepted_name_lsid" text
|
856 |
|
|
);
|
857 |
|
|
|
858 |
|
|
|
859 |
|
|
--
|
860 |
11964
|
aaronmk
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
|
861 |
|
|
--
|
862 |
|
|
|
863 |
|
|
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
|
864 |
14111
|
aaronmk
|
SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
|
865 |
|
|
taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
|
866 |
|
|
COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
|
867 |
|
|
taxon_match."*Genus_matched" AS scrubbed_genus,
|
868 |
|
|
taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
|
869 |
|
|
taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
|
870 |
|
|
taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
|
871 |
|
|
taxon_match."*Name_matched_author" AS scrubbed_author,
|
872 |
|
|
taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
|
873 |
|
|
(taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
|
874 |
13861
|
aaronmk
|
FROM taxon_match;
|
875 |
11964
|
aaronmk
|
|
876 |
|
|
|
877 |
|
|
--
|
878 |
11965
|
aaronmk
|
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
|
879 |
|
|
--
|
880 |
|
|
|
881 |
13575
|
aaronmk
|
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
|
882 |
13846
|
aaronmk
|
to modify:
|
883 |
|
|
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
|
884 |
|
|
SELECT __
|
885 |
|
|
$$);
|
886 |
|
|
|
887 |
13575
|
aaronmk
|
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.
|
888 |
|
|
';
|
889 |
11965
|
aaronmk
|
|
890 |
|
|
|
891 |
|
|
--
|
892 |
11964
|
aaronmk
|
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
|
893 |
|
|
--
|
894 |
|
|
|
895 |
|
|
CREATE VIEW taxon_scrub AS
|
896 |
13800
|
aaronmk
|
SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
|
897 |
14108
|
aaronmk
|
"ValidMatchedTaxon".batch,
|
898 |
14105
|
aaronmk
|
"ValidMatchedTaxon".match_num,
|
899 |
14111
|
aaronmk
|
"ValidMatchedTaxon"."*Name_number",
|
900 |
|
|
"ValidMatchedTaxon"."*Name_submitted",
|
901 |
|
|
"ValidMatchedTaxon"."*Overall_score",
|
902 |
|
|
"ValidMatchedTaxon"."*Name_matched",
|
903 |
|
|
"ValidMatchedTaxon"."*Name_matched_rank",
|
904 |
|
|
"ValidMatchedTaxon"."*Name_score",
|
905 |
|
|
"ValidMatchedTaxon"."*Name_matched_author",
|
906 |
|
|
"ValidMatchedTaxon"."*Name_matched_url",
|
907 |
|
|
"ValidMatchedTaxon"."*Author_matched",
|
908 |
|
|
"ValidMatchedTaxon"."*Author_score",
|
909 |
|
|
"ValidMatchedTaxon"."*Family_matched",
|
910 |
|
|
"ValidMatchedTaxon"."*Family_score",
|
911 |
|
|
"ValidMatchedTaxon"."*Name_matched_accepted_family",
|
912 |
|
|
"ValidMatchedTaxon"."*Genus_matched",
|
913 |
|
|
"ValidMatchedTaxon"."*Genus_score",
|
914 |
|
|
"ValidMatchedTaxon"."*Specific_epithet_matched",
|
915 |
|
|
"ValidMatchedTaxon"."*Specific_epithet_score",
|
916 |
|
|
"ValidMatchedTaxon"."*Infraspecific_rank",
|
917 |
|
|
"ValidMatchedTaxon"."*Infraspecific_epithet_matched",
|
918 |
|
|
"ValidMatchedTaxon"."*Infraspecific_epithet_score",
|
919 |
|
|
"ValidMatchedTaxon"."*Infraspecific_rank_2",
|
920 |
|
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
|
921 |
|
|
"ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
|
922 |
|
|
"ValidMatchedTaxon"."*Annotations",
|
923 |
|
|
"ValidMatchedTaxon"."*Unmatched_terms",
|
924 |
|
|
"ValidMatchedTaxon"."*Taxonomic_status",
|
925 |
|
|
"ValidMatchedTaxon"."*Accepted_name",
|
926 |
|
|
"ValidMatchedTaxon"."*Accepted_name_author",
|
927 |
|
|
"ValidMatchedTaxon"."*Accepted_name_rank",
|
928 |
|
|
"ValidMatchedTaxon"."*Accepted_name_url",
|
929 |
|
|
"ValidMatchedTaxon"."*Accepted_name_species",
|
930 |
|
|
"ValidMatchedTaxon"."*Accepted_name_family",
|
931 |
|
|
"ValidMatchedTaxon"."*Selected",
|
932 |
|
|
"ValidMatchedTaxon"."*Source",
|
933 |
|
|
"ValidMatchedTaxon"."*Warnings",
|
934 |
|
|
"ValidMatchedTaxon"."*Accepted_name_lsid",
|
935 |
14108
|
aaronmk
|
"ValidMatchedTaxon".is_valid_match,
|
936 |
14103
|
aaronmk
|
"ValidMatchedTaxon"."taxonomicStatus",
|
937 |
13800
|
aaronmk
|
"ValidMatchedTaxon".accepted_morphospecies_binomial,
|
938 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
|
939 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
|
940 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
|
941 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
|
942 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
|
943 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
|
944 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
|
945 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
|
946 |
|
|
"taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
|
947 |
13532
|
aaronmk
|
CASE
|
948 |
14111
|
aaronmk
|
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")
|
949 |
|
|
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")
|
950 |
13532
|
aaronmk
|
ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
|
951 |
|
|
END AS scrubbed_morphospecies_binomial
|
952 |
11964
|
aaronmk
|
FROM ("ValidMatchedTaxon"
|
953 |
|
|
LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
|
954 |
|
|
|
955 |
|
|
|
956 |
|
|
--
|
957 |
|
|
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
|
958 |
|
|
--
|
959 |
|
|
|
960 |
13443
|
aaronmk
|
COMMENT ON VIEW taxon_scrub IS '
|
961 |
13531
|
aaronmk
|
to modify:
|
962 |
13845
|
aaronmk
|
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
|
963 |
13647
|
aaronmk
|
SELECT __
|
964 |
13531
|
aaronmk
|
$$);
|
965 |
13443
|
aaronmk
|
';
|
966 |
11964
|
aaronmk
|
|
967 |
|
|
|
968 |
|
|
--
|
969 |
10778
|
aaronmk
|
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
970 |
|
|
--
|
971 |
|
|
|
972 |
|
|
ALTER TABLE ONLY batch_download_settings
|
973 |
|
|
ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
|
974 |
|
|
|
975 |
|
|
|
976 |
|
|
--
|
977 |
|
|
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
978 |
|
|
--
|
979 |
|
|
|
980 |
|
|
ALTER TABLE ONLY batch
|
981 |
|
|
ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
|
982 |
|
|
|
983 |
|
|
|
984 |
|
|
--
|
985 |
|
|
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
986 |
|
|
--
|
987 |
|
|
|
988 |
|
|
ALTER TABLE ONLY batch
|
989 |
|
|
ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
|
990 |
|
|
|
991 |
|
|
|
992 |
|
|
--
|
993 |
|
|
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
994 |
|
|
--
|
995 |
|
|
|
996 |
|
|
ALTER TABLE ONLY client_version
|
997 |
|
|
ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
|
998 |
|
|
|
999 |
|
|
|
1000 |
|
|
--
|
1001 |
13868
|
aaronmk
|
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
|
1002 |
10778
|
aaronmk
|
--
|
1003 |
|
|
|
1004 |
13861
|
aaronmk
|
ALTER TABLE ONLY taxon_match
|
1005 |
13868
|
aaronmk
|
ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
|
1006 |
10778
|
aaronmk
|
|
1007 |
14125
|
aaronmk
|
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
|
1008 |
10778
|
aaronmk
|
|
1009 |
14125
|
aaronmk
|
|
1010 |
10778
|
aaronmk
|
--
|
1011 |
10793
|
aaronmk
|
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1012 |
|
|
--
|
1013 |
|
|
|
1014 |
|
|
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
|
1015 |
|
|
|
1016 |
|
|
|
1017 |
|
|
--
|
1018 |
13879
|
aaronmk
|
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1019 |
13589
|
aaronmk
|
--
|
1020 |
|
|
|
1021 |
14111
|
aaronmk
|
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
|
1022 |
13589
|
aaronmk
|
|
1023 |
|
|
|
1024 |
|
|
--
|
1025 |
13879
|
aaronmk
|
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1026 |
13874
|
aaronmk
|
--
|
1027 |
|
|
|
1028 |
14111
|
aaronmk
|
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
|
1029 |
13874
|
aaronmk
|
|
1030 |
|
|
|
1031 |
|
|
--
|
1032 |
13879
|
aaronmk
|
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
|
1033 |
11607
|
aaronmk
|
--
|
1034 |
|
|
|
1035 |
14111
|
aaronmk
|
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
|
1036 |
11607
|
aaronmk
|
|
1037 |
|
|
|
1038 |
|
|
--
|
1039 |
10778
|
aaronmk
|
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1040 |
|
|
--
|
1041 |
|
|
|
1042 |
|
|
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
|
1043 |
|
|
|
1044 |
|
|
|
1045 |
|
|
--
|
1046 |
13868
|
aaronmk
|
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
|
1047 |
13866
|
aaronmk
|
--
|
1048 |
|
|
|
1049 |
13868
|
aaronmk
|
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
|
1050 |
13866
|
aaronmk
|
|
1051 |
|
|
|
1052 |
|
|
--
|
1053 |
13868
|
aaronmk
|
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1054 |
13567
|
aaronmk
|
--
|
1055 |
|
|
|
1056 |
13868
|
aaronmk
|
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
|
1057 |
13567
|
aaronmk
|
|
1058 |
|
|
|
1059 |
|
|
--
|
1060 |
14122
|
aaronmk
|
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
|
1061 |
|
|
--
|
1062 |
|
|
|
1063 |
|
|
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
|
1064 |
|
|
|
1065 |
|
|
|
1066 |
|
|
--
|
1067 |
13868
|
aaronmk
|
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
|
1068 |
13578
|
aaronmk
|
--
|
1069 |
|
|
|
1070 |
13868
|
aaronmk
|
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
|
1071 |
13578
|
aaronmk
|
|
1072 |
|
|
|
1073 |
|
|
--
|
1074 |
13868
|
aaronmk
|
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
|
1075 |
10778
|
aaronmk
|
--
|
1076 |
|
|
|
1077 |
13868
|
aaronmk
|
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();
|
1078 |
10778
|
aaronmk
|
|
1079 |
|
|
|
1080 |
|
|
--
|
1081 |
|
|
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1082 |
|
|
--
|
1083 |
|
|
|
1084 |
|
|
ALTER TABLE ONLY batch
|
1085 |
|
|
ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1086 |
|
|
|
1087 |
|
|
|
1088 |
|
|
--
|
1089 |
|
|
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1090 |
|
|
--
|
1091 |
|
|
|
1092 |
|
|
ALTER TABLE ONLY batch_download_settings
|
1093 |
|
|
ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1094 |
|
|
|
1095 |
|
|
|
1096 |
|
|
--
|
1097 |
13868
|
aaronmk
|
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
|
1098 |
10778
|
aaronmk
|
--
|
1099 |
|
|
|
1100 |
13861
|
aaronmk
|
ALTER TABLE ONLY taxon_match
|
1101 |
13868
|
aaronmk
|
ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
1102 |
10778
|
aaronmk
|
|
1103 |
|
|
|
1104 |
|
|
--
|
1105 |
|
|
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
|
1106 |
|
|
--
|
1107 |
|
|
|
1108 |
|
|
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
|
1109 |
|
|
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
|
1110 |
|
|
GRANT ALL ON SCHEMA "TNRS" TO bien;
|
1111 |
|
|
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
|
1112 |
|
|
|
1113 |
|
|
|
1114 |
|
|
--
|
1115 |
13861
|
aaronmk
|
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
|
1116 |
10778
|
aaronmk
|
--
|
1117 |
|
|
|
1118 |
13861
|
aaronmk
|
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
|
1119 |
|
|
REVOKE ALL ON TABLE taxon_match FROM bien;
|
1120 |
|
|
GRANT ALL ON TABLE taxon_match TO bien;
|
1121 |
|
|
GRANT SELECT ON TABLE taxon_match TO bien_read;
|
1122 |
10778
|
aaronmk
|
|
1123 |
|
|
|
1124 |
|
|
--
|
1125 |
13878
|
aaronmk
|
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
|
1126 |
|
|
--
|
1127 |
|
|
|
1128 |
|
|
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
|
1129 |
|
|
REVOKE ALL ON TABLE taxon_best_match FROM bien;
|
1130 |
|
|
GRANT ALL ON TABLE taxon_best_match TO bien;
|
1131 |
|
|
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
|
1132 |
|
|
|
1133 |
|
|
|
1134 |
|
|
--
|
1135 |
11912
|
aaronmk
|
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1136 |
|
|
--
|
1137 |
|
|
|
1138 |
|
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
|
1139 |
|
|
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
|
1140 |
|
|
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
|
1141 |
|
|
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
|
1142 |
|
|
|
1143 |
|
|
|
1144 |
|
|
--
|
1145 |
|
|
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
|
1146 |
|
|
--
|
1147 |
|
|
|
1148 |
|
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
|
1149 |
|
|
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
|
1150 |
|
|
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
|
1151 |
|
|
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
|
1152 |
|
|
|
1153 |
|
|
|
1154 |
|
|
--
|
1155 |
13866
|
aaronmk
|
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
|
1156 |
|
|
--
|
1157 |
|
|
|
1158 |
|
|
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
|
1159 |
|
|
REVOKE ALL ON TABLE taxon_match_input FROM bien;
|
1160 |
|
|
GRANT ALL ON TABLE taxon_match_input TO bien;
|
1161 |
|
|
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
|
1162 |
|
|
|
1163 |
|
|
|
1164 |
|
|
--
|
1165 |
11912
|
aaronmk
|
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
|
1166 |
|
|
--
|
1167 |
|
|
|
1168 |
|
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
|
1169 |
|
|
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
|
1170 |
|
|
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
|
1171 |
|
|
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
|
1172 |
|
|
|
1173 |
|
|
|
1174 |
|
|
--
|
1175 |
|
|
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
|
1176 |
|
|
--
|
1177 |
|
|
|
1178 |
|
|
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
|
1179 |
|
|
REVOKE ALL ON TABLE taxon_scrub FROM bien;
|
1180 |
|
|
GRANT ALL ON TABLE taxon_scrub TO bien;
|
1181 |
|
|
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
|
1182 |
|
|
|
1183 |
|
|
|
1184 |
|
|
--
|
1185 |
10778
|
aaronmk
|
-- PostgreSQL database dump complete
|
1186 |
|
|
--
|