Project

General

Profile

1
--
2
-- PostgreSQL database dump
3
--
4

    
5
SET statement_timeout = 0;
6
SET lock_timeout = 0;
7
SET client_encoding = 'UTF8';
8
SET standard_conforming_strings = on;
9
SET check_function_bodies = false;
10
SET client_min_messages = warning;
11

    
12
--
13
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
14
--
15

    
16
--CREATE SCHEMA "TNRS";
17

    
18

    
19
--
20
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
21
--
22

    
23
COMMENT ON SCHEMA "TNRS" IS '
24
IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
25
on vegbiendev:
26
# back up existing TNRS schema (in case of an accidental incorrect change):
27
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
28
$ svn up
29
$ svn di
30
# make the changes shown in the diff
31
## to change column types:
32
SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[
33
  (''col'', ''new_type'')
34
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
35
$ rm=1 inputs/.TNRS/schema.sql.run
36
# repeat until `svn di` shows no diff
37
# back up new TNRS schema:
38
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
39
';
40

    
41

    
42
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
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
$$;
57

    
58

    
59
--
60
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
61
--
62

    
63
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

    
69

    
70
--
71
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
72
--
73

    
74
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

    
80

    
81
--
82
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
83
--
84

    
85
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
86
    LANGUAGE sql IMMUTABLE
87
    AS $_$
88
/* 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
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
92
$_$;
93

    
94

    
95
--
96
-- Name: remove_prefix(text, text, boolean, boolean); Type: FUNCTION; Schema: TNRS; Owner: -
97
--
98

    
99
CREATE FUNCTION remove_prefix(prefix text, str text, require boolean DEFAULT true, case_sensitive boolean DEFAULT true) RETURNS text
100
    LANGUAGE sql IMMUTABLE
101
    AS $$
102
SELECT util.remove_prefix(prefix, str, require, case_sensitive)
103
$$;
104

    
105

    
106
--
107
-- Name: FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean); Type: COMMENT; Schema: TNRS; Owner: -
108
--
109

    
110
COMMENT ON FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean) IS '
111
wrapper that prevents views from getting dropped when the util schema is reinstalled
112
';
113

    
114

    
115
--
116
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
117
--
118

    
119
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
120
    LANGUAGE plpgsql
121
    AS $$
122
BEGIN
123
	PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
124
	RETURN NULL;
125
END;
126
$$;
127

    
128

    
129
--
130
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
131
--
132

    
133
CREATE FUNCTION taxon_match__fill() RETURNS trigger
134
    LANGUAGE plpgsql
135
    AS $$
136
BEGIN
137
	DECLARE
138
		"Specific_epithet_is_plant" boolean :=
139
			(CASE
140
			WHEN   new."*Infraspecific_epithet_matched"	 IS NOT NULL
141
				OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
142
				OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
143
				THEN true
144
			ELSE NULL -- ambiguous
145
			END);
146
		never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
147
			-- author disambiguates
148
		family_is_homonym boolean = NOT never_homonym
149
			AND "TNRS".family_is_homonym(new."*Family_matched");
150
		genus_is_homonym  boolean = NOT never_homonym
151
			AND "TNRS".genus_is_homonym(new."*Genus_matched");
152
	BEGIN
153
		/* exclude homonyms because these are not valid matches (TNRS provides a
154
		name, but the name is not meaningful because it is not unambiguous) */
155
		new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
156
			AND COALESCE(CASE
157
			WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
158
				THEN true
159
			ELSE -- consider genus
160
				(CASE
161
				WHEN new."*Genus_score" =  1	   -- exact match
162
					THEN
163
					(CASE
164
					WHEN NOT genus_is_homonym THEN true
165
					ELSE "Specific_epithet_is_plant"
166
					END)
167
				WHEN new."*Genus_score" >= 0.85 -- fuzzy match
168
					THEN "Specific_epithet_is_plant"
169
				ELSE NULL -- ambiguous
170
				END)
171
			END, false);
172
	END;
173
	
174
	DECLARE
175
		matched_taxon_name_with_author text = NULLIF(concat_ws(' '
176
			, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
177
				new."*Name_matched")
178
			, NULLIF(new."*Name_matched", 'No suitable matches found.')
179
			, new."*Name_matched_author"
180
			), '');
181
		accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
182
			, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
183
				new."*Accepted_name")
184
			, new."*Accepted_name"
185
			, new."*Accepted_name_author"
186
			), '');
187
	BEGIN
188
		new.scrubbed_unique_taxon_name = COALESCE(
189
			accepted_taxon_name_with_author, matched_taxon_name_with_author);
190
	END;
191
	
192
	RETURN new;
193
END;
194
$$;
195

    
196

    
197
--
198
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
199
--
200

    
201
COMMENT ON FUNCTION taxon_match__fill() IS '
202
IMPORTANT: when changing this function, you must regenerate the derived cols:
203
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
204
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
205
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
206
runtime: 1.5 min ("92633 ms")
207
';
208

    
209

    
210
--
211
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
212
--
213

    
214
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
215
    LANGUAGE plpgsql
216
    AS $$
217
BEGIN
218
	-- clear derived cols so old values won't be used in calculations
219
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL;
220
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
221
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = NULL;
222
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
223
	new.matched_has_accepted = NULL;
224
	new."Accepted_family__@TNRS__@vegpath.org" = NULL;
225
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = NULL;
226
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = NULL;
227
	new."[accepted_]genus__@DwC__@vegpath.org" = NULL;
228
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = NULL;
229
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
230
	new.__accepted_infraspecific_label = NULL;
231
	new."__accepted_infraspecific_{rank,epithet}" = NULL;
232
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
233
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
234
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
235
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = NULL;
236
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = NULL;
237
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
238
	new."[scrubbed_]genus__@DwC__@vegpath.org" = NULL;
239
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = NULL;
240
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
241
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
242
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
243
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
244
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
245
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
246
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
247
	
248
	-- populate derived cols
249
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new);
250
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new);
251
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = (SELECT NULLIF("*Name_matched", 'No suitable matches found.'::text) FROM (SELECT new.*) new);
252
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new);
253
	new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new);
254
	new."Accepted_family__@TNRS__@vegpath.org" = (SELECT COALESCE("*Accepted_name_family",
255
CASE
256
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
257
    ELSE NULL::text
258
END) FROM (SELECT new.*) new);
259
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = (SELECT rtrim("*Accepted_name_species", ' '::text) FROM (SELECT new.*) new);
260
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = (SELECT regexp_split_to_array("*Accepted_name", ' '::text) FROM (SELECT new.*) new);
261
	new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1] FROM (SELECT new.*) new);
262
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2] FROM (SELECT new.*) new);
263
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
264
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
265
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
266
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
267
END FROM (SELECT new.*) new);
268
	new.__accepted_infraspecific_label = (SELECT ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''::text), ' '::text) FROM (SELECT new.*) new);
269
	new."__accepted_infraspecific_{rank,epithet}" = (SELECT NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], '{}'::text[]) FROM (SELECT new.*) new);
270
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[1] FROM (SELECT new.*) new);
271
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[2] FROM (SELECT new.*) new);
272
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text) FROM (SELECT new.*) new);
273
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = (SELECT "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name") FROM (SELECT new.*) new);
274
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT CASE
275
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
276
    ELSE "*Name_matched_rank"
277
END FROM (SELECT new.*) new);
278
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
279
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
280
    ELSE "*Name_matched_accepted_family"
281
END FROM (SELECT new.*) new);
282
	new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT CASE
283
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
284
    ELSE "*Genus_matched"
285
END FROM (SELECT new.*) new);
286
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT CASE
287
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
288
    ELSE "*Specific_epithet_matched"
289
END FROM (SELECT new.*) new);
290
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
291
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
292
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
293
END FROM (SELECT new.*) new);
294
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
295
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
296
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
297
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
298
END FROM (SELECT new.*) new);
299
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT CASE
300
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
301
    ELSE "*Infraspecific_rank"
302
END FROM (SELECT new.*) new);
303
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT CASE
304
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
305
    ELSE "*Infraspecific_epithet_matched"
306
END FROM (SELECT new.*) new);
307
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
308
    WHEN matched_has_accepted THEN "*Accepted_name"
309
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
310
END FROM (SELECT new.*) new);
311
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
312
    WHEN matched_has_accepted THEN "*Accepted_name_author"
313
    ELSE "*Name_matched_author"
314
END FROM (SELECT new.*) new);
315
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT CASE
316
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
317
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
318
END FROM (SELECT new.*) new);
319
	
320
	RETURN new;
321
END;
322
$$;
323

    
324

    
325
--
326
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
327
--
328

    
329
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
330
autogenerated, do not edit
331

    
332
to regenerate:
333
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
334
';
335

    
336

    
337
--
338
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
339
--
340

    
341
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
342
    LANGUAGE plpgsql
343
    AS $$
344
BEGIN
345
	IF new.match_num IS NULL THEN
346
		new.match_num = "TNRS".taxon_match__match_num__next();
347
	END IF;
348
	RETURN new;
349
END;
350
$$;
351

    
352

    
353
--
354
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
355
--
356

    
357
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
358
    LANGUAGE sql
359
    AS $$
360
SELECT nextval('pg_temp.taxon_match__match_num__seq');
361
$$;
362

    
363

    
364
--
365
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
366
--
367

    
368
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
369
    LANGUAGE plpgsql
370
    AS $$
371
BEGIN
372
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
373
	RETURN NULL;
374
END;
375
$$;
376

    
377

    
378
--
379
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
380
--
381

    
382
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
383
    LANGUAGE sql IMMUTABLE
384
    AS $_$
385
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
386
$_$;
387

    
388

    
389
--
390
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
391
--
392

    
393
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
394
    LANGUAGE sql IMMUTABLE
395
    AS $$
396
SELECT ARRAY[
397
]::text[]
398
$$;
399

    
400

    
401
SET default_tablespace = '';
402

    
403
SET default_with_oids = false;
404

    
405
--
406
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
407
--
408

    
409
CREATE TABLE taxon_match (
410
    batch text DEFAULT now() NOT NULL,
411
    match_num integer NOT NULL,
412
    "*Name_number" integer NOT NULL,
413
    "*Name_submitted" text NOT NULL,
414
    "*Overall_score" double precision,
415
    "*Name_matched" text,
416
    "*Name_matched_rank" text,
417
    "*Name_score" double precision,
418
    "*Name_matched_author" text,
419
    "*Name_matched_url" text,
420
    "*Author_matched" text,
421
    "*Author_score" double precision,
422
    "*Family_matched" text,
423
    "*Family_score" double precision,
424
    "*Name_matched_accepted_family" text,
425
    "*Genus_matched" text,
426
    "*Genus_score" double precision,
427
    "*Specific_epithet_matched" text,
428
    "*Specific_epithet_score" double precision,
429
    "*Infraspecific_rank" text,
430
    "*Infraspecific_epithet_matched" text,
431
    "*Infraspecific_epithet_score" double precision,
432
    "*Infraspecific_rank_2" text,
433
    "*Infraspecific_epithet_2_matched" text,
434
    "*Infraspecific_epithet_2_score" double precision,
435
    "*Annotations" text,
436
    "*Unmatched_terms" text,
437
    "*Taxonomic_status" text,
438
    "*Accepted_name" text,
439
    "*Accepted_name_author" text,
440
    "*Accepted_name_rank" text,
441
    "*Accepted_name_url" text,
442
    "*Accepted_name_species" text,
443
    "*Accepted_name_family" text,
444
    "*Selected" text,
445
    "*Source" text,
446
    "*Warnings" text,
447
    "*Accepted_name_lsid" text,
448
    is_valid_match boolean NOT NULL,
449
    scrubbed_unique_taxon_name text,
450
    "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" text,
451
    "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" text,
452
    "matched~Name[_no_author]___@TNRS__@vegpath.org" text,
453
    "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" text,
454
    matched_has_accepted boolean,
455
    "Accepted_family__@TNRS__@vegpath.org" text,
456
    "Accepted_species[_binomial]__@TNRS__@vegpath.org" text,
457
    "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" text[],
458
    "[accepted_]genus__@DwC__@vegpath.org" text,
459
    "[accepted_]specificEpithet__@DwC__@vegpath.org" text,
460
    "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
461
    __accepted_infraspecific_label text,
462
    "__accepted_infraspecific_{rank,epithet}" text[],
463
    "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
464
    "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
465
    "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" text,
466
    "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" text,
467
    "[scrubbed_]taxonRank__@DwC__@vegpath.org" text,
468
    "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" text,
469
    "[scrubbed_]genus__@DwC__@vegpath.org" text,
470
    "[scrubbed_]specificEpithet__@DwC__@vegpath.org" text,
471
    "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" text,
472
    "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
473
    "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
474
    "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" text,
475
    "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" text,
476
    "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" text,
477
    "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" text,
478
    CONSTRAINT "Accepted_family__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_family__@TNRS__@vegpath.org" IS DISTINCT FROM COALESCE("*Accepted_name_family",
479
CASE
480
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
481
    ELSE NULL::text
482
END)))),
483
    CONSTRAINT "Accepted_species[_binomial]__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_species[_binomial]__@TNRS__@vegpath.org" IS DISTINCT FROM rtrim("*Accepted_name_species", ' '::text)))),
484
    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]))),
485
    CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]))),
486
    CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
487
    CONSTRAINT "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
488
CASE
489
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
490
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
491
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
492
END))),
493
    CONSTRAINT "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text))))),
494
    CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]))),
495
    CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
496
    CONSTRAINT "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM (("*Genus_matched" || ' '::text) || "*Specific_epithet_matched")))),
497
    CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))),
498
    CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM
499
CASE
500
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
501
    ELSE "*Infraspecific_rank"
502
END))),
503
    CONSTRAINT "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
504
CASE
505
    WHEN matched_has_accepted THEN "*Accepted_name_author"
506
    ELSE "*Name_matched_author"
507
END))),
508
    CONSTRAINT "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
509
CASE
510
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
511
    ELSE "*Name_matched_accepted_family"
512
END))),
513
    CONSTRAINT "[scrubbed_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]genus__@DwC__@vegpath.org" IS DISTINCT FROM
514
CASE
515
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
516
    ELSE "*Genus_matched"
517
END))),
518
    CONSTRAINT "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
519
CASE
520
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
521
    ELSE "*Infraspecific_epithet_matched"
522
END))),
523
    CONSTRAINT "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
524
CASE
525
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
526
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
527
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
528
END))),
529
    CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
530
CASE
531
    WHEN matched_has_accepted THEN "*Accepted_name"
532
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
533
END))),
534
    CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM
535
CASE
536
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
537
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
538
END))),
539
    CONSTRAINT "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
540
CASE
541
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
542
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
543
END))),
544
    CONSTRAINT "[scrubbed_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
545
CASE
546
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
547
    ELSE "*Specific_epithet_matched"
548
END))),
549
    CONSTRAINT "[scrubbed_]taxonRank__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonRank__@DwC__@vegpath.org" IS DISTINCT FROM
550
CASE
551
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
552
    ELSE "*Name_matched_rank"
553
END))),
554
    CONSTRAINT "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS DISTINCT FROM map_taxonomic_status("*Taxonomic_status", "*Accepted_name")))),
555
    CONSTRAINT __accepted_infraspecific_label CHECK ((NOT (__accepted_infraspecific_label IS DISTINCT FROM ltrim(NULLIF(remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''::text), ' '::text)))),
556
    CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], '{}'::text[])))),
557
    CONSTRAINT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" CHECK ((NOT ("__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name", ' '::text)))),
558
    CONSTRAINT matched_has_accepted CHECK ((NOT (matched_has_accepted IS DISTINCT FROM ("*Accepted_name" IS NOT NULL)))),
559
    CONSTRAINT "matched~Name[_no_author]___@TNRS__@vegpath.org" CHECK ((NOT ("matched~Name[_no_author]___@TNRS__@vegpath.org" IS DISTINCT FROM NULLIF("*Name_matched", 'No suitable matches found.'::text))))
560
);
561

    
562

    
563
--
564
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
565
--
566

    
567
COMMENT ON TABLE taxon_match IS '
568
whenever columns are renamed:
569
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
570

    
571
to port derived column changes to vegbiendev:
572
SELECT util.derived_cols_export(''"TNRS".taxon_match'');
573
# run the returned SQL on vegbiendev
574
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
575
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
576

    
577
to add a new derived column:
578
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''col''), $$
579
expr
580
$$));
581
SELECT util.derived_cols_populate(''"TNRS".taxon_match'');
582
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
583
$ make schemas/remake
584

    
585
to remove a column:
586
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
587
$ make schemas/remake
588

    
589
to move a derived column to the middle or to add a non-derived column:
590
make the changes in inputs/.TNRS/schema.sql
591
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS; runtime: 1 min ("1m2.629s")
592
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
593
SELECT util.derived_cols_repopulate(''"TNRS".taxon_match'');
594
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
595
$ make schemas/remake
596

    
597
to add a constraint: runtime: 3 min ("173620 ms")
598
';
599

    
600

    
601
--
602
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
603
--
604

    
605
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
606
= "*Unmatched_terms"
607

    
608
derived column
609

    
610
to modify expr:
611
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col, $$"*Unmatched_terms"$$)::util.derived_col_def);
612
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
613

    
614
to rename:
615
# rename column
616
# rename CHECK constraint
617
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
618

    
619
to drop:
620
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col);
621
	-- DROP __ CASCADE doesn''t work when there are dependent views
622
';
623

    
624

    
625
--
626
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
627
--
628

    
629
COMMENT ON COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
630
= ("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"
631

    
632
derived column
633

    
634
to modify expr:
635
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"$$)::util.derived_col_def);
636
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
637

    
638
to rename:
639
# rename column
640
# rename CHECK constraint
641
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
642

    
643
to drop:
644
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
645
	-- DROP __ CASCADE doesn''t work when there are dependent views
646
';
647

    
648

    
649
--
650
-- Name: COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
651
--
652

    
653
COMMENT ON COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org" IS '
654
= NULLIF("*Name_matched", ''No suitable matches found.''::text)
655

    
656
derived column
657

    
658
to modify expr:
659
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched~Name[_no_author]___@TNRS__@vegpath.org'')::util.col, $$NULLIF("*Name_matched", ''No suitable matches found.''::text)$$)::util.derived_col_def);
660
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
661

    
662
to rename:
663
# rename column
664
# rename CHECK constraint
665
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
666

    
667
to drop:
668
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''matched~Name[_no_author]___@TNRS__@vegpath.org'')::util.col);
669
	-- DROP __ CASCADE doesn''t work when there are dependent views
670
';
671

    
672

    
673
--
674
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
675
--
676

    
677
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
678
= "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
679

    
680
derived column
681

    
682
to modify expr:
683
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
684
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
685

    
686
to rename:
687
# rename column
688
# rename CHECK constraint
689
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
690

    
691
to drop:
692
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
693
	-- DROP __ CASCADE doesn''t work when there are dependent views
694
';
695

    
696

    
697
--
698
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
699
--
700

    
701
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
702
= "*Accepted_name" IS NOT NULL
703

    
704
derived column
705

    
706
to modify expr:
707
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
708
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
709

    
710
to rename:
711
# rename column
712
# rename CHECK constraint
713
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
714

    
715
to drop:
716
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col);
717
	-- DROP __ CASCADE doesn''t work when there are dependent views
718
';
719

    
720

    
721
--
722
-- Name: COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
723
--
724

    
725
COMMENT ON COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org" IS '
726
= COALESCE("*Accepted_name_family",
727
CASE
728
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
729
    ELSE NULL::text
730
END)
731

    
732
derived column
733

    
734
to modify expr:
735
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col, $$COALESCE("*Accepted_name_family",
736
CASE
737
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
738
    ELSE NULL::text
739
END)$$)::util.derived_col_def);
740
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
741

    
742
to rename:
743
# rename column
744
# rename CHECK constraint
745
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
746

    
747
to drop:
748
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col);
749
	-- DROP __ CASCADE doesn''t work when there are dependent views
750
';
751

    
752

    
753
--
754
-- Name: COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
755
--
756

    
757
COMMENT ON COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org" IS '
758
= rtrim("*Accepted_name_species", '' ''::text)
759

    
760
derived column
761

    
762
to modify expr:
763
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_species[_binomial]__@TNRS__@vegpath.org'')::util.col, $$rtrim("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
764
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
765

    
766
to rename:
767
# rename column
768
# rename CHECK constraint
769
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
770

    
771
to drop:
772
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''Accepted_species[_binomial]__@TNRS__@vegpath.org'')::util.col);
773
	-- DROP __ CASCADE doesn''t work when there are dependent views
774
';
775

    
776

    
777
--
778
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}"; Type: COMMENT; Schema: TNRS; Owner: -
779
--
780

    
781
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS '
782
= regexp_split_to_array("*Accepted_name", '' ''::text)
783

    
784
derived column
785

    
786
to modify expr:
787
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet,infra_{rank,epithet}}'')::util.col, $$regexp_split_to_array("*Accepted_name", '' ''::text)$$)::util.derived_col_def);
788
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
789

    
790
to rename:
791
# rename column
792
# rename CHECK constraint
793
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
794

    
795
to drop:
796
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet,infra_{rank,epithet}}'')::util.col);
797
	-- DROP __ CASCADE doesn''t work when there are dependent views
798
';
799

    
800

    
801
--
802
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
803
--
804

    
805
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
806
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]
807

    
808
derived column
809

    
810
to modify expr:
811
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]$$)::util.derived_col_def);
812
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
813

    
814
to rename:
815
# rename column
816
# rename CHECK constraint
817
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
818

    
819
to drop:
820
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col);
821
	-- DROP __ CASCADE doesn''t work when there are dependent views
822
';
823

    
824

    
825
--
826
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
827
--
828

    
829
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
830
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]
831

    
832
derived column
833

    
834
to modify expr:
835
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]$$)::util.derived_col_def);
836
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
837

    
838
to rename:
839
# rename column
840
# rename CHECK constraint
841
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
842

    
843
to drop:
844
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col);
845
	-- DROP __ CASCADE doesn''t work when there are dependent views
846
';
847

    
848

    
849
--
850
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
851
--
852

    
853
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
854
= CASE
855
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
856
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
857
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
858
END
859

    
860
derived column
861

    
862
to modify expr:
863
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
864
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
865
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
866
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
867
END$$)::util.derived_col_def);
868
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
869

    
870
to rename:
871
# rename column
872
# rename CHECK constraint
873
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
874

    
875
to drop:
876
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col);
877
	-- DROP __ CASCADE doesn''t work when there are dependent views
878
';
879

    
880

    
881
--
882
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
883
--
884

    
885
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
886
= ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''''::text), '' ''::text)
887

    
888
derived column
889

    
890
to modify expr:
891
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''''::text), '' ''::text)$$)::util.derived_col_def);
892
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
893

    
894
to rename:
895
# rename column
896
# rename CHECK constraint
897
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
898

    
899
to drop:
900
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col);
901
	-- DROP __ CASCADE doesn''t work when there are dependent views
902
';
903

    
904

    
905
--
906
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
907
--
908

    
909
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
910
= NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], ''{}''::text[])
911

    
912
derived column
913

    
914
to modify expr:
915
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], ''{}''::text[])$$)::util.derived_col_def);
916
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
917

    
918
to rename:
919
# rename column
920
# rename CHECK constraint
921
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
922

    
923
to drop:
924
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col);
925
	-- DROP __ CASCADE doesn''t work when there are dependent views
926
';
927

    
928

    
929
--
930
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
931
--
932

    
933
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
934
= "__accepted_infraspecific_{rank,epithet}"[1]
935

    
936
derived column
937

    
938
to modify expr:
939
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);
940
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
941

    
942
to rename:
943
# rename column
944
# rename CHECK constraint
945
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
946

    
947
to drop:
948
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
949
	-- DROP __ CASCADE doesn''t work when there are dependent views
950
';
951

    
952

    
953
--
954
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
955
--
956

    
957
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
958
= "__accepted_infraspecific_{rank,epithet}"[2]
959

    
960
derived column
961

    
962
to modify expr:
963
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
964
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
965

    
966
to rename:
967
# rename column
968
# rename CHECK constraint
969
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
970

    
971
to drop:
972
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col);
973
	-- DROP __ CASCADE doesn''t work when there are dependent views
974
';
975

    
976

    
977
--
978
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
979
--
980

    
981
COMMENT ON COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
982
= "*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)
983

    
984
derived column
985

    
986
to modify expr:
987
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)$$)::util.derived_col_def);
988
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
989

    
990
to rename:
991
# rename column
992
# rename CHECK constraint
993
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
994

    
995
to drop:
996
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
997
	-- DROP __ CASCADE doesn''t work when there are dependent views
998
';
999

    
1000

    
1001
--
1002
-- Name: COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1003
--
1004

    
1005
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS '
1006
= "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")
1007

    
1008
derived column
1009

    
1010
to modify expr:
1011
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonomicStatus__@DwC__@vegpath.org'')::util.col, $$"TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")$$)::util.derived_col_def);
1012
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1013

    
1014
to rename:
1015
# rename column
1016
# rename CHECK constraint
1017
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1018

    
1019
to drop:
1020
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]taxonomicStatus__@DwC__@vegpath.org'')::util.col);
1021
	-- DROP __ CASCADE doesn''t work when there are dependent views
1022
';
1023

    
1024

    
1025
--
1026
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1027
--
1028

    
1029
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
1030
= CASE
1031
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1032
    ELSE "*Name_matched_rank"
1033
END
1034

    
1035
derived column
1036

    
1037
to modify expr:
1038
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
1039
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1040
    ELSE "*Name_matched_rank"
1041
END$$)::util.derived_col_def);
1042
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1043

    
1044
to rename:
1045
# rename column
1046
# rename CHECK constraint
1047
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1048

    
1049
to drop:
1050
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col);
1051
	-- DROP __ CASCADE doesn''t work when there are dependent views
1052
';
1053

    
1054

    
1055
--
1056
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1057
--
1058

    
1059
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1060
= CASE
1061
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1062
    ELSE "*Name_matched_accepted_family"
1063
END
1064

    
1065
derived column
1066

    
1067
to modify expr:
1068
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1069
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1070
    ELSE "*Name_matched_accepted_family"
1071
END$$)::util.derived_col_def);
1072
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1073

    
1074
to rename:
1075
# rename column
1076
# rename CHECK constraint
1077
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1078

    
1079
to drop:
1080
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1081
	-- DROP __ CASCADE doesn''t work when there are dependent views
1082
';
1083

    
1084

    
1085
--
1086
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1087
--
1088

    
1089
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
1090
= CASE
1091
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1092
    ELSE "*Genus_matched"
1093
END
1094

    
1095
derived column
1096

    
1097
to modify expr:
1098
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
1099
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1100
    ELSE "*Genus_matched"
1101
END$$)::util.derived_col_def);
1102
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1103

    
1104
to rename:
1105
# rename column
1106
# rename CHECK constraint
1107
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1108

    
1109
to drop:
1110
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col);
1111
	-- DROP __ CASCADE doesn''t work when there are dependent views
1112
';
1113

    
1114

    
1115
--
1116
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1117
--
1118

    
1119
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
1120
= CASE
1121
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1122
    ELSE "*Specific_epithet_matched"
1123
END
1124

    
1125
derived column
1126

    
1127
to modify expr:
1128
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1129
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1130
    ELSE "*Specific_epithet_matched"
1131
END$$)::util.derived_col_def);
1132
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1133

    
1134
to rename:
1135
# rename column
1136
# rename CHECK constraint
1137
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1138

    
1139
to drop:
1140
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col);
1141
	-- DROP __ CASCADE doesn''t work when there are dependent views
1142
';
1143

    
1144

    
1145
--
1146
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1147
--
1148

    
1149
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1150
= CASE
1151
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1152
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1153
END
1154

    
1155
derived column
1156

    
1157
to modify expr:
1158
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1159
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1160
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1161
END$$)::util.derived_col_def);
1162
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1163

    
1164
to rename:
1165
# rename column
1166
# rename CHECK constraint
1167
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1168

    
1169
to drop:
1170
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1171
	-- DROP __ CASCADE doesn''t work when there are dependent views
1172
';
1173

    
1174

    
1175
--
1176
-- Name: COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1177
--
1178

    
1179
COMMENT ON COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1180
= CASE
1181
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1182
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1183
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1184
END
1185

    
1186
derived column
1187

    
1188
to modify expr:
1189
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1190
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1191
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1192
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1193
END$$)::util.derived_col_def);
1194
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1195

    
1196
to rename:
1197
# rename column
1198
# rename CHECK constraint
1199
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1200

    
1201
to drop:
1202
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col);
1203
	-- DROP __ CASCADE doesn''t work when there are dependent views
1204
';
1205

    
1206

    
1207
--
1208
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1209
--
1210

    
1211
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
1212
= CASE
1213
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1214
    ELSE "*Infraspecific_rank"
1215
END
1216

    
1217
derived column
1218

    
1219
to modify expr:
1220
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
1221
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1222
    ELSE "*Infraspecific_rank"
1223
END$$)::util.derived_col_def);
1224
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1225

    
1226
to rename:
1227
# rename column
1228
# rename CHECK constraint
1229
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1230

    
1231
to drop:
1232
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
1233
	-- DROP __ CASCADE doesn''t work when there are dependent views
1234
';
1235

    
1236

    
1237
--
1238
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1239
--
1240

    
1241
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
1242
= CASE
1243
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1244
    ELSE "*Infraspecific_epithet_matched"
1245
END
1246

    
1247
derived column
1248

    
1249
to modify expr:
1250
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1251
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1252
    ELSE "*Infraspecific_epithet_matched"
1253
END$$)::util.derived_col_def);
1254
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1255

    
1256
to rename:
1257
# rename column
1258
# rename CHECK constraint
1259
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1260

    
1261
to drop:
1262
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col);
1263
	-- DROP __ CASCADE doesn''t work when there are dependent views
1264
';
1265

    
1266

    
1267
--
1268
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1269
--
1270

    
1271
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1272
= CASE
1273
    WHEN matched_has_accepted THEN "*Accepted_name"
1274
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1275
END
1276

    
1277
derived column
1278

    
1279
to modify expr:
1280
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1281
    WHEN matched_has_accepted THEN "*Accepted_name"
1282
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1283
END$$)::util.derived_col_def);
1284
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1285

    
1286
to rename:
1287
# rename column
1288
# rename CHECK constraint
1289
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1290

    
1291
to drop:
1292
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1293
	-- DROP __ CASCADE doesn''t work when there are dependent views
1294
';
1295

    
1296

    
1297
--
1298
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1299
--
1300

    
1301
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1302
= CASE
1303
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1304
    ELSE "*Name_matched_author"
1305
END
1306

    
1307
derived column
1308

    
1309
to modify expr:
1310
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1311
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1312
    ELSE "*Name_matched_author"
1313
END$$)::util.derived_col_def);
1314
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1315

    
1316
to rename:
1317
# rename column
1318
# rename CHECK constraint
1319
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1320

    
1321
to drop:
1322
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1323
	-- DROP __ CASCADE doesn''t work when there are dependent views
1324
';
1325

    
1326

    
1327
--
1328
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1329
--
1330

    
1331
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1332
= CASE
1333
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1334
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1335
END
1336

    
1337
derived column
1338

    
1339
to modify expr:
1340
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1341
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1342
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1343
END$$)::util.derived_col_def);
1344
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1345

    
1346
to rename:
1347
# rename column
1348
# rename CHECK constraint
1349
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1350

    
1351
to drop:
1352
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
1353
	-- DROP __ CASCADE doesn''t work when there are dependent views
1354
';
1355

    
1356

    
1357
--
1358
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1359
--
1360

    
1361
CREATE VIEW taxon_best_match AS
1362
 SELECT taxon_match.batch,
1363
    taxon_match.match_num,
1364
    taxon_match."*Name_number",
1365
    taxon_match."*Name_submitted",
1366
    taxon_match."*Overall_score",
1367
    taxon_match."*Name_matched",
1368
    taxon_match."*Name_matched_rank",
1369
    taxon_match."*Name_score",
1370
    taxon_match."*Name_matched_author",
1371
    taxon_match."*Name_matched_url",
1372
    taxon_match."*Author_matched",
1373
    taxon_match."*Author_score",
1374
    taxon_match."*Family_matched",
1375
    taxon_match."*Family_score",
1376
    taxon_match."*Name_matched_accepted_family",
1377
    taxon_match."*Genus_matched",
1378
    taxon_match."*Genus_score",
1379
    taxon_match."*Specific_epithet_matched",
1380
    taxon_match."*Specific_epithet_score",
1381
    taxon_match."*Infraspecific_rank",
1382
    taxon_match."*Infraspecific_epithet_matched",
1383
    taxon_match."*Infraspecific_epithet_score",
1384
    taxon_match."*Infraspecific_rank_2",
1385
    taxon_match."*Infraspecific_epithet_2_matched",
1386
    taxon_match."*Infraspecific_epithet_2_score",
1387
    taxon_match."*Annotations",
1388
    taxon_match."*Unmatched_terms",
1389
    taxon_match."*Taxonomic_status",
1390
    taxon_match."*Accepted_name",
1391
    taxon_match."*Accepted_name_author",
1392
    taxon_match."*Accepted_name_rank",
1393
    taxon_match."*Accepted_name_url",
1394
    taxon_match."*Accepted_name_species",
1395
    taxon_match."*Accepted_name_family",
1396
    taxon_match."*Selected",
1397
    taxon_match."*Source",
1398
    taxon_match."*Warnings",
1399
    taxon_match."*Accepted_name_lsid",
1400
    taxon_match.is_valid_match,
1401
    taxon_match.scrubbed_unique_taxon_name,
1402
    taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1403
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1404
    taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1405
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1406
    taxon_match.matched_has_accepted,
1407
    taxon_match."Accepted_family__@TNRS__@vegpath.org",
1408
    taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1409
    taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1410
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1411
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1412
    taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1413
    taxon_match.__accepted_infraspecific_label,
1414
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1415
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1416
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1417
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1418
    taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1419
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1420
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1421
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1422
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1423
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1424
    taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1425
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1426
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1427
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1428
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1429
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1430
   FROM taxon_match
1431
  WHERE (taxon_match."*Selected" = 'true'::text);
1432

    
1433

    
1434
--
1435
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1436
--
1437

    
1438
COMMENT ON VIEW taxon_best_match IS '
1439
to modify:
1440
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1441
SELECT __
1442
$$);
1443
';
1444

    
1445

    
1446
--
1447
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1448
--
1449

    
1450
CREATE VIEW "MatchedTaxon" AS
1451
 SELECT taxon_best_match.batch,
1452
    taxon_best_match.match_num,
1453
    taxon_best_match."*Name_number",
1454
    taxon_best_match."*Name_submitted",
1455
    taxon_best_match."*Overall_score",
1456
    taxon_best_match."*Name_matched",
1457
    taxon_best_match."*Name_matched_rank",
1458
    taxon_best_match."*Name_score",
1459
    taxon_best_match."*Name_matched_author",
1460
    taxon_best_match."*Name_matched_url",
1461
    taxon_best_match."*Author_matched",
1462
    taxon_best_match."*Author_score",
1463
    taxon_best_match."*Family_matched",
1464
    taxon_best_match."*Family_score",
1465
    taxon_best_match."*Name_matched_accepted_family",
1466
    taxon_best_match."*Genus_matched",
1467
    taxon_best_match."*Genus_score",
1468
    taxon_best_match."*Specific_epithet_matched",
1469
    taxon_best_match."*Specific_epithet_score",
1470
    taxon_best_match."*Infraspecific_rank",
1471
    taxon_best_match."*Infraspecific_epithet_matched",
1472
    taxon_best_match."*Infraspecific_epithet_score",
1473
    taxon_best_match."*Infraspecific_rank_2",
1474
    taxon_best_match."*Infraspecific_epithet_2_matched",
1475
    taxon_best_match."*Infraspecific_epithet_2_score",
1476
    taxon_best_match."*Annotations",
1477
    taxon_best_match."*Unmatched_terms",
1478
    taxon_best_match."*Taxonomic_status",
1479
    taxon_best_match."*Accepted_name",
1480
    taxon_best_match."*Accepted_name_author",
1481
    taxon_best_match."*Accepted_name_rank",
1482
    taxon_best_match."*Accepted_name_url",
1483
    taxon_best_match."*Accepted_name_species",
1484
    taxon_best_match."*Accepted_name_family",
1485
    taxon_best_match."*Selected",
1486
    taxon_best_match."*Source",
1487
    taxon_best_match."*Warnings",
1488
    taxon_best_match."*Accepted_name_lsid",
1489
    taxon_best_match.is_valid_match,
1490
    taxon_best_match.scrubbed_unique_taxon_name,
1491
    taxon_best_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1492
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1493
    taxon_best_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1494
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1495
    taxon_best_match.matched_has_accepted,
1496
    taxon_best_match."Accepted_family__@TNRS__@vegpath.org",
1497
    taxon_best_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1498
    taxon_best_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1499
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1500
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1501
    taxon_best_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1502
    taxon_best_match.__accepted_infraspecific_label,
1503
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1504
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1505
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1506
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1507
    taxon_best_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1508
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1509
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1510
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1511
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1512
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1513
    taxon_best_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1514
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1515
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1516
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1517
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1518
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1519
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1520
        CASE
1521
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1522
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1523
            ELSE taxon_best_match."*Accepted_name_species"
1524
        END AS accepted_morphospecies_binomial
1525
   FROM taxon_best_match;
1526

    
1527

    
1528
--
1529
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1530
--
1531

    
1532
COMMENT ON VIEW "MatchedTaxon" IS '
1533
to modify:
1534
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1535
SELECT __
1536
$$);
1537
';
1538

    
1539

    
1540
--
1541
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1542
--
1543

    
1544
CREATE VIEW "ValidMatchedTaxon" AS
1545
 SELECT "MatchedTaxon".batch,
1546
    "MatchedTaxon".match_num,
1547
    "MatchedTaxon"."*Name_number",
1548
    "MatchedTaxon"."*Name_submitted",
1549
    "MatchedTaxon"."*Overall_score",
1550
    "MatchedTaxon"."*Name_matched",
1551
    "MatchedTaxon"."*Name_matched_rank",
1552
    "MatchedTaxon"."*Name_score",
1553
    "MatchedTaxon"."*Name_matched_author",
1554
    "MatchedTaxon"."*Name_matched_url",
1555
    "MatchedTaxon"."*Author_matched",
1556
    "MatchedTaxon"."*Author_score",
1557
    "MatchedTaxon"."*Family_matched",
1558
    "MatchedTaxon"."*Family_score",
1559
    "MatchedTaxon"."*Name_matched_accepted_family",
1560
    "MatchedTaxon"."*Genus_matched",
1561
    "MatchedTaxon"."*Genus_score",
1562
    "MatchedTaxon"."*Specific_epithet_matched",
1563
    "MatchedTaxon"."*Specific_epithet_score",
1564
    "MatchedTaxon"."*Infraspecific_rank",
1565
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1566
    "MatchedTaxon"."*Infraspecific_epithet_score",
1567
    "MatchedTaxon"."*Infraspecific_rank_2",
1568
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1569
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1570
    "MatchedTaxon"."*Annotations",
1571
    "MatchedTaxon"."*Unmatched_terms",
1572
    "MatchedTaxon"."*Taxonomic_status",
1573
    "MatchedTaxon"."*Accepted_name",
1574
    "MatchedTaxon"."*Accepted_name_author",
1575
    "MatchedTaxon"."*Accepted_name_rank",
1576
    "MatchedTaxon"."*Accepted_name_url",
1577
    "MatchedTaxon"."*Accepted_name_species",
1578
    "MatchedTaxon"."*Accepted_name_family",
1579
    "MatchedTaxon"."*Selected",
1580
    "MatchedTaxon"."*Source",
1581
    "MatchedTaxon"."*Warnings",
1582
    "MatchedTaxon"."*Accepted_name_lsid",
1583
    "MatchedTaxon".is_valid_match,
1584
    "MatchedTaxon".scrubbed_unique_taxon_name,
1585
    "MatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1586
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1587
    "MatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1588
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1589
    "MatchedTaxon".matched_has_accepted,
1590
    "MatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1591
    "MatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1592
    "MatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1593
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1594
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1595
    "MatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1596
    "MatchedTaxon".__accepted_infraspecific_label,
1597
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1598
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1599
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1600
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1601
    "MatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1602
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1603
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1604
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1605
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1606
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1607
    "MatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1608
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1609
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1610
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1611
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1612
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1613
    "MatchedTaxon"."taxonomicStatus",
1614
    "MatchedTaxon".accepted_morphospecies_binomial
1615
   FROM "MatchedTaxon"
1616
  WHERE "MatchedTaxon".is_valid_match;
1617

    
1618

    
1619
--
1620
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1621
--
1622

    
1623
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1624
to update, use * as the column list
1625
';
1626

    
1627

    
1628
--
1629
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1630
--
1631

    
1632
CREATE TABLE batch (
1633
    id text NOT NULL,
1634
    id_by_time text,
1635
    time_submitted timestamp with time zone DEFAULT now(),
1636
    client_version text
1637
);
1638

    
1639

    
1640
--
1641
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1642
--
1643

    
1644
CREATE TABLE batch_download_settings (
1645
    id text NOT NULL,
1646
    "E-mail" text,
1647
    "Id" text,
1648
    "Job type" text,
1649
    "Contains Id" boolean,
1650
    "Start time" text,
1651
    "Finish time" text,
1652
    "TNRS version" text,
1653
    "Sources selected" text,
1654
    "Match threshold" double precision,
1655
    "Classification" text,
1656
    "Allow partial matches?" boolean,
1657
    "Sort by source" boolean,
1658
    "Constrain by higher taxonomy" boolean
1659
);
1660

    
1661

    
1662
--
1663
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1664
--
1665

    
1666
COMMENT ON TABLE batch_download_settings IS '
1667
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1668
';
1669

    
1670

    
1671
--
1672
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1673
--
1674

    
1675
CREATE TABLE client_version (
1676
    id text NOT NULL,
1677
    global_rev integer NOT NULL,
1678
    "/lib/tnrs.py rev" integer,
1679
    "/bin/tnrs_db rev" integer
1680
);
1681

    
1682

    
1683
--
1684
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1685
--
1686

    
1687
COMMENT ON TABLE client_version IS '
1688
contains svn revisions
1689
';
1690

    
1691

    
1692
--
1693
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1694
--
1695

    
1696
COMMENT ON COLUMN client_version.global_rev IS '
1697
from `svn info .` > Last Changed Rev
1698
';
1699

    
1700

    
1701
--
1702
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1703
--
1704

    
1705
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1706
from `svn info lib/tnrs.py` > Last Changed Rev
1707
';
1708

    
1709

    
1710
--
1711
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1712
--
1713

    
1714
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1715
from `svn info bin/tnrs_db` > Last Changed Rev
1716
';
1717

    
1718

    
1719
--
1720
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1721
--
1722

    
1723
CREATE VIEW taxon_match_input AS
1724
 SELECT taxon_match."*Name_number" AS "Name_number",
1725
    taxon_match."*Name_submitted" AS "Name_submitted",
1726
    taxon_match."*Overall_score" AS "Overall_score",
1727
    taxon_match."*Name_matched" AS "Name_matched",
1728
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1729
    taxon_match."*Name_score" AS "Name_score",
1730
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1731
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1732
    taxon_match."*Author_matched" AS "Author_matched",
1733
    taxon_match."*Author_score" AS "Author_score",
1734
    taxon_match."*Family_matched" AS "Family_matched",
1735
    taxon_match."*Family_score" AS "Family_score",
1736
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1737
    taxon_match."*Genus_matched" AS "Genus_matched",
1738
    taxon_match."*Genus_score" AS "Genus_score",
1739
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1740
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1741
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1742
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1743
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1744
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1745
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1746
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1747
    taxon_match."*Annotations" AS "Annotations",
1748
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1749
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1750
    taxon_match."*Accepted_name" AS "Accepted_name",
1751
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1752
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1753
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1754
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1755
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1756
    taxon_match."*Selected" AS "Selected",
1757
    taxon_match."*Source" AS "Source",
1758
    taxon_match."*Warnings" AS "Warnings",
1759
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1760
   FROM taxon_match;
1761

    
1762

    
1763
--
1764
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1765
--
1766

    
1767
CREATE TABLE taxon_match_input__copy_to (
1768
    "Name_number" integer,
1769
    "Name_submitted" text,
1770
    "Overall_score" double precision,
1771
    "Name_matched" text,
1772
    "Name_matched_rank" text,
1773
    "Name_score" double precision,
1774
    "Name_matched_author" text,
1775
    "Name_matched_url" text,
1776
    "Author_matched" text,
1777
    "Author_score" double precision,
1778
    "Family_matched" text,
1779
    "Family_score" double precision,
1780
    "Name_matched_accepted_family" text,
1781
    "Genus_matched" text,
1782
    "Genus_score" double precision,
1783
    "Specific_epithet_matched" text,
1784
    "Specific_epithet_score" double precision,
1785
    "Infraspecific_rank" text,
1786
    "Infraspecific_epithet_matched" text,
1787
    "Infraspecific_epithet_score" double precision,
1788
    "Infraspecific_rank_2" text,
1789
    "Infraspecific_epithet_2_matched" text,
1790
    "Infraspecific_epithet_2_score" double precision,
1791
    "Annotations" text,
1792
    "Unmatched_terms" text,
1793
    "Taxonomic_status" text,
1794
    "Accepted_name" text,
1795
    "Accepted_name_author" text,
1796
    "Accepted_name_rank" text,
1797
    "Accepted_name_url" text,
1798
    "Accepted_name_species" text,
1799
    "Accepted_name_family" text,
1800
    "Selected" text,
1801
    "Source" text,
1802
    "Warnings" text,
1803
    "Accepted_name_lsid" text
1804
);
1805

    
1806

    
1807
--
1808
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1809
--
1810

    
1811
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1812
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1813
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1814
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1815
    taxon_match."*Genus_matched" AS scrubbed_genus,
1816
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1817
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1818
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1819
    taxon_match."*Name_matched_author" AS scrubbed_author,
1820
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1821
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1822
   FROM taxon_match;
1823

    
1824

    
1825
--
1826
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1827
--
1828

    
1829
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1830
to modify:
1831
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1832
SELECT __
1833
$$);
1834

    
1835
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.
1836
';
1837

    
1838

    
1839
--
1840
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1841
--
1842

    
1843
CREATE VIEW taxon_scrub AS
1844
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1845
    "ValidMatchedTaxon".batch,
1846
    "ValidMatchedTaxon".match_num,
1847
    "ValidMatchedTaxon"."*Name_number",
1848
    "ValidMatchedTaxon"."*Name_submitted",
1849
    "ValidMatchedTaxon"."*Overall_score",
1850
    "ValidMatchedTaxon"."*Name_matched",
1851
    "ValidMatchedTaxon"."*Name_matched_rank",
1852
    "ValidMatchedTaxon"."*Name_score",
1853
    "ValidMatchedTaxon"."*Name_matched_author",
1854
    "ValidMatchedTaxon"."*Name_matched_url",
1855
    "ValidMatchedTaxon"."*Author_matched",
1856
    "ValidMatchedTaxon"."*Author_score",
1857
    "ValidMatchedTaxon"."*Family_matched",
1858
    "ValidMatchedTaxon"."*Family_score",
1859
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1860
    "ValidMatchedTaxon"."*Genus_matched",
1861
    "ValidMatchedTaxon"."*Genus_score",
1862
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1863
    "ValidMatchedTaxon"."*Specific_epithet_score",
1864
    "ValidMatchedTaxon"."*Infraspecific_rank",
1865
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1866
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1867
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1868
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1869
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1870
    "ValidMatchedTaxon"."*Annotations",
1871
    "ValidMatchedTaxon"."*Unmatched_terms",
1872
    "ValidMatchedTaxon"."*Taxonomic_status",
1873
    "ValidMatchedTaxon"."*Accepted_name",
1874
    "ValidMatchedTaxon"."*Accepted_name_author",
1875
    "ValidMatchedTaxon"."*Accepted_name_rank",
1876
    "ValidMatchedTaxon"."*Accepted_name_url",
1877
    "ValidMatchedTaxon"."*Accepted_name_species",
1878
    "ValidMatchedTaxon"."*Accepted_name_family",
1879
    "ValidMatchedTaxon"."*Selected",
1880
    "ValidMatchedTaxon"."*Source",
1881
    "ValidMatchedTaxon"."*Warnings",
1882
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1883
    "ValidMatchedTaxon".is_valid_match,
1884
    "ValidMatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1885
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1886
    "ValidMatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1887
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1888
    "ValidMatchedTaxon".matched_has_accepted,
1889
    "ValidMatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1890
    "ValidMatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1891
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1892
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1893
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1894
    "ValidMatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1895
    "ValidMatchedTaxon".__accepted_infraspecific_label,
1896
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1897
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1898
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1899
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1900
    "ValidMatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1901
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1902
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1903
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1904
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1905
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1906
    "ValidMatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1907
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1908
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1909
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1910
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1911
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1912
    "ValidMatchedTaxon"."taxonomicStatus",
1913
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1914
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1915
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1916
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1917
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1918
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1919
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1920
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1921
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1922
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1923
        CASE
1924
            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")
1925
            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")
1926
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1927
        END AS scrubbed_morphospecies_binomial
1928
   FROM ("ValidMatchedTaxon"
1929
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1930

    
1931

    
1932
--
1933
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1934
--
1935

    
1936
COMMENT ON VIEW taxon_scrub IS '
1937
to modify:
1938
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1939
SELECT __
1940
$$);
1941
';
1942

    
1943

    
1944
--
1945
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1946
--
1947

    
1948
ALTER TABLE ONLY batch_download_settings
1949
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1950

    
1951

    
1952
--
1953
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1954
--
1955

    
1956
ALTER TABLE ONLY batch
1957
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1958

    
1959

    
1960
--
1961
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1962
--
1963

    
1964
ALTER TABLE ONLY batch
1965
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1966

    
1967

    
1968
--
1969
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1970
--
1971

    
1972
ALTER TABLE ONLY client_version
1973
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1974

    
1975

    
1976
--
1977
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1978
--
1979

    
1980
ALTER TABLE ONLY taxon_match
1981
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1982

    
1983
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1984

    
1985

    
1986
--
1987
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1988
--
1989

    
1990
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1991

    
1992

    
1993
--
1994
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1995
--
1996

    
1997
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
1998

    
1999

    
2000
--
2001
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
2002
--
2003

    
2004
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
2005

    
2006

    
2007
--
2008
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
2009
--
2010

    
2011
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
2012

    
2013

    
2014
--
2015
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2016
--
2017

    
2018
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
2019

    
2020

    
2021
--
2022
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
2023
--
2024

    
2025
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
2026

    
2027

    
2028
--
2029
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2030
--
2031

    
2032
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
2033

    
2034

    
2035
--
2036
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
2037
--
2038

    
2039
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
2040

    
2041

    
2042
--
2043
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2044
--
2045

    
2046
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
2047

    
2048

    
2049
--
2050
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
2051
--
2052

    
2053
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();
2054

    
2055

    
2056
--
2057
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2058
--
2059

    
2060
ALTER TABLE ONLY batch
2061
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
2062

    
2063

    
2064
--
2065
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2066
--
2067

    
2068
ALTER TABLE ONLY batch_download_settings
2069
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2070

    
2071

    
2072
--
2073
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2074
--
2075

    
2076
ALTER TABLE ONLY taxon_match
2077
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2078

    
2079

    
2080
--
2081
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
2082
--
2083

    
2084
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
2085
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
2086
GRANT ALL ON SCHEMA "TNRS" TO bien;
2087
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
2088

    
2089

    
2090
--
2091
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
2092
--
2093

    
2094
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
2095
REVOKE ALL ON TABLE taxon_match FROM bien;
2096
GRANT ALL ON TABLE taxon_match TO bien;
2097
GRANT SELECT ON TABLE taxon_match TO bien_read;
2098

    
2099

    
2100
--
2101
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
2102
--
2103

    
2104
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
2105
REVOKE ALL ON TABLE taxon_best_match FROM bien;
2106
GRANT ALL ON TABLE taxon_best_match TO bien;
2107
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
2108

    
2109

    
2110
--
2111
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2112
--
2113

    
2114
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
2115
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
2116
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
2117
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
2118

    
2119

    
2120
--
2121
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2122
--
2123

    
2124
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
2125
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
2126
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
2127
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
2128

    
2129

    
2130
--
2131
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
2132
--
2133

    
2134
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
2135
REVOKE ALL ON TABLE taxon_match_input FROM bien;
2136
GRANT ALL ON TABLE taxon_match_input TO bien;
2137
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
2138

    
2139

    
2140
--
2141
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
2142
--
2143

    
2144
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
2145
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
2146
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
2147
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
2148

    
2149

    
2150
--
2151
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
2152
--
2153

    
2154
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
2155
REVOKE ALL ON TABLE taxon_scrub FROM bien;
2156
GRANT ALL ON TABLE taxon_scrub TO bien;
2157
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
2158

    
2159

    
2160
--
2161
-- PostgreSQL database dump complete
2162
--
2163

    
(7-7/9)