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: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
97
--
98

    
99
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
100
    LANGUAGE plpgsql
101
    AS $$
102
BEGIN
103
	PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
104
	RETURN NULL;
105
END;
106
$$;
107

    
108

    
109
--
110
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
111
--
112

    
113
CREATE FUNCTION taxon_match__fill() RETURNS trigger
114
    LANGUAGE plpgsql
115
    AS $$
116
BEGIN
117
	DECLARE
118
		"Specific_epithet_is_plant" boolean :=
119
			(CASE
120
			WHEN   new."*Infraspecific_epithet_matched"	 IS NOT NULL
121
				OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
122
				OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
123
				THEN true
124
			ELSE NULL -- ambiguous
125
			END);
126
		never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
127
			-- author disambiguates
128
		family_is_homonym boolean = NOT never_homonym
129
			AND "TNRS".family_is_homonym(new."*Family_matched");
130
		genus_is_homonym  boolean = NOT never_homonym
131
			AND "TNRS".genus_is_homonym(new."*Genus_matched");
132
	BEGIN
133
		/* exclude homonyms because these are not valid matches (TNRS provides a
134
		name, but the name is not meaningful because it is not unambiguous) */
135
		new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
136
			AND COALESCE(CASE
137
			WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
138
				THEN true
139
			ELSE -- consider genus
140
				(CASE
141
				WHEN new."*Genus_score" =  1	   -- exact match
142
					THEN
143
					(CASE
144
					WHEN NOT genus_is_homonym THEN true
145
					ELSE "Specific_epithet_is_plant"
146
					END)
147
				WHEN new."*Genus_score" >= 0.85 -- fuzzy match
148
					THEN "Specific_epithet_is_plant"
149
				ELSE NULL -- ambiguous
150
				END)
151
			END, false);
152
	END;
153
	
154
	DECLARE
155
		matched_taxon_name_with_author text = NULLIF(concat_ws(' '
156
			, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
157
				new."*Name_matched")
158
			, NULLIF(new."*Name_matched", 'No suitable matches found.')
159
			, new."*Name_matched_author"
160
			), '');
161
		accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
162
			, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
163
				new."*Accepted_name")
164
			, new."*Accepted_name"
165
			, new."*Accepted_name_author"
166
			), '');
167
	BEGIN
168
		new.scrubbed_unique_taxon_name = COALESCE(
169
			accepted_taxon_name_with_author, matched_taxon_name_with_author);
170
	END;
171
	
172
	RETURN new;
173
END;
174
$$;
175

    
176

    
177
--
178
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
179
--
180

    
181
COMMENT ON FUNCTION taxon_match__fill() IS '
182
IMPORTANT: when changing this function, you must regenerate the derived cols:
183
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
184
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
185
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
186
runtime: 1.5 min ("92633 ms")
187
';
188

    
189

    
190
--
191
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
192
--
193

    
194
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
195
    LANGUAGE plpgsql
196
    AS $$
197
BEGIN
198
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT
199
		("*Genus_matched" || ' '::text) || "*Specific_epithet_matched"
200
		FROM (SELECT new.*) new);
201
	
202
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT
203
		"*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text)
204
		FROM (SELECT new.*) new);
205
	
206
	new.matched_has_accepted = (SELECT
207
		"*Accepted_name" IS NOT NULL
208
		FROM (SELECT new.*) new);
209
	
210
	new."__accepted_{genus,specific_epithet}" = (SELECT
211
		regexp_split_to_array("*Accepted_name_species", ' '::text)
212
		FROM (SELECT new.*) new);
213
	
214
	new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT
215
		"__accepted_{genus,specific_epithet}"[1]
216
		FROM (SELECT new.*) new);
217
	
218
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT
219
		"__accepted_{genus,specific_epithet}"[2]
220
		FROM (SELECT new.*) new);
221
	
222
	new.__accepted_infraspecific_label = (SELECT
223
		ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)
224
		FROM (SELECT new.*) new);
225
	
226
	new."__accepted_infraspecific_{rank,epithet}" = (SELECT
227
		regexp_split_to_array(__accepted_infraspecific_label, ' '::text)
228
		FROM (SELECT new.*) new);
229
	
230
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT
231
		"__accepted_infraspecific_{rank,epithet}"[1]
232
		FROM (SELECT new.*) new);
233
	
234
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT
235
		"__accepted_infraspecific_{rank,epithet}"[2]
236
		FROM (SELECT new.*) new);
237
	
238
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT
239
		"*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text)
240
		FROM (SELECT new.*) new);
241
	
242
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT
243
		CASE
244
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
245
    ELSE "*Name_matched_rank"
246
END
247
		FROM (SELECT new.*) new);
248
	
249
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT
250
		CASE
251
    WHEN matched_has_accepted THEN "*Accepted_name_family"
252
    ELSE "*Name_matched_accepted_family"
253
END
254
		FROM (SELECT new.*) new);
255
	
256
	new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT
257
		CASE
258
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
259
    ELSE "*Genus_matched"
260
END
261
		FROM (SELECT new.*) new);
262
	
263
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT
264
		CASE
265
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
266
    ELSE "*Specific_epithet_matched"
267
END
268
		FROM (SELECT new.*) new);
269
	
270
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT
271
		CASE
272
    WHEN matched_has_accepted THEN "*Accepted_name_species"
273
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
274
END
275
		FROM (SELECT new.*) new);
276
	
277
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT
278
		CASE
279
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
280
    ELSE "*Infraspecific_rank"
281
END
282
		FROM (SELECT new.*) new);
283
	
284
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT
285
		CASE
286
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
287
    ELSE "*Infraspecific_epithet_matched"
288
END
289
		FROM (SELECT new.*) new);
290
	
291
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT
292
		CASE
293
    WHEN matched_has_accepted THEN "*Accepted_name"
294
    ELSE "*Name_matched"
295
END
296
		FROM (SELECT new.*) new);
297
	
298
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT
299
		CASE
300
    WHEN matched_has_accepted THEN "*Accepted_name_author"
301
    ELSE "*Name_matched_author"
302
END
303
		FROM (SELECT new.*) new);
304
	
305
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT
306
		CASE
307
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
308
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
309
END
310
		FROM (SELECT new.*) new);
311
	
312
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT
313
		"*Unmatched_terms"
314
		FROM (SELECT new.*) new);
315
	
316
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT
317
		CASE
318
        WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
319
        WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
320
        ELSE "*Accepted_name_species"
321
    END
322
		FROM (SELECT new.*) new);
323
	
324
	RETURN new;
325
END;
326
$$;
327

    
328

    
329
--
330
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
331
--
332

    
333
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
334
autogenerated, do not edit
335

    
336
to regenerate:
337
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
338
';
339

    
340

    
341
--
342
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
343
--
344

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

    
356

    
357
--
358
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
359
--
360

    
361
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
362
    LANGUAGE sql
363
    AS $$
364
SELECT nextval('pg_temp.taxon_match__match_num__seq');
365
$$;
366

    
367

    
368
--
369
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
370
--
371

    
372
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
373
    LANGUAGE plpgsql
374
    AS $$
375
BEGIN
376
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
377
	RETURN NULL;
378
END;
379
$$;
380

    
381

    
382
--
383
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
384
--
385

    
386
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
387
    LANGUAGE sql IMMUTABLE
388
    AS $_$
389
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
390
$_$;
391

    
392

    
393
--
394
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
395
--
396

    
397
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
398
    LANGUAGE sql IMMUTABLE
399
    AS $$
400
SELECT ARRAY[
401
]::text[]
402
$$;
403

    
404

    
405
SET default_tablespace = '';
406

    
407
SET default_with_oids = false;
408

    
409
--
410
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
411
--
412

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

    
547

    
548
--
549
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
550
--
551

    
552
COMMENT ON TABLE taxon_match IS '
553
whenever columns are renamed:
554
SELECT util.derived_cols_sync(''"TNRS".taxon_match'');
555

    
556
to remove columns or add columns at the end:
557
$ rm=1 inputs/.TNRS/data.sql.run
558
$ make schemas/remake
559

    
560
to add columns in the middle:
561
make the changes in inputs/.TNRS/schema.sql
562
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
563
$ make schemas/remake
564

    
565
to populate a new column:
566
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
567
UPDATE "TNRS".taxon_match SET "col" = value;
568
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
569
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
570
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
571
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
572

    
573
to add a constraint: runtime: 3 min ("173620 ms")
574
';
575

    
576

    
577
--
578
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
579
--
580

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

    
584
derived column
585

    
586
to modify expr:
587
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);
588
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
589

    
590
to rename:
591
# rename column
592
# rename CHECK constraint
593
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
594
';
595

    
596

    
597
--
598
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
599
--
600

    
601
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
602
= "*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
603

    
604
derived column
605

    
606
to modify expr:
607
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
608
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
609

    
610
to rename:
611
# rename column
612
# rename CHECK constraint
613
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
614
';
615

    
616

    
617
--
618
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
619
--
620

    
621
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
622
= "*Accepted_name" IS NOT NULL
623

    
624
derived column
625

    
626
to modify expr:
627
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
628
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
629

    
630
to rename:
631
# rename column
632
# rename CHECK constraint
633
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
634
';
635

    
636

    
637
--
638
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
639
--
640

    
641
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
642
= regexp_split_to_array("*Accepted_name_species", '' ''::text)
643

    
644
derived column
645

    
646
to modify expr:
647
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet}'')::util.col, $$regexp_split_to_array("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
648
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
649

    
650
to rename:
651
# rename column
652
# rename CHECK constraint
653
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
654
';
655

    
656

    
657
--
658
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
659
--
660

    
661
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
662
= "__accepted_{genus,specific_epithet}"[1]
663

    
664
derived column
665

    
666
to modify expr:
667
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[1]$$)::util.derived_col_def);
668
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
669

    
670
to rename:
671
# rename column
672
# rename CHECK constraint
673
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
674
';
675

    
676

    
677
--
678
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
679
--
680

    
681
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
682
= "__accepted_{genus,specific_epithet}"[2]
683

    
684
derived column
685

    
686
to modify expr:
687
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[2]$$)::util.derived_col_def);
688
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
689

    
690
to rename:
691
# rename column
692
# rename CHECK constraint
693
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
694
';
695

    
696

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

    
701
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
702
= ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''::text), '' ''::text)
703

    
704
derived column
705

    
706
to modify expr:
707
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''::text), '' ''::text)$$)::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

    
716

    
717
--
718
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
719
--
720

    
721
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
722
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
723

    
724
derived column
725

    
726
to modify expr:
727
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)$$)::util.derived_col_def);
728
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
729

    
730
to rename:
731
# rename column
732
# rename CHECK constraint
733
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
734
';
735

    
736

    
737
--
738
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
739
--
740

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

    
744
derived column
745

    
746
to modify expr:
747
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);
748
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
749

    
750
to rename:
751
# rename column
752
# rename CHECK constraint
753
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
754
';
755

    
756

    
757
--
758
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
759
--
760

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

    
764
derived column
765

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

    
770
to rename:
771
# rename column
772
# rename CHECK constraint
773
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
774
';
775

    
776

    
777
--
778
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
779
--
780

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

    
784
derived column
785

    
786
to modify expr:
787
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);
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

    
796

    
797
--
798
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
799
--
800

    
801
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
802
= CASE
803
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
804
    ELSE "*Name_matched_rank"
805
END
806

    
807
derived column
808

    
809
to modify expr:
810
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
811
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
812
    ELSE "*Name_matched_rank"
813
END$$)::util.derived_col_def);
814
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
815

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

    
822

    
823
--
824
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
825
--
826

    
827
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
828
= CASE
829
    WHEN matched_has_accepted THEN "*Accepted_name_family"
830
    ELSE "*Name_matched_accepted_family"
831
END
832

    
833
derived column
834

    
835
to modify expr:
836
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
837
    WHEN matched_has_accepted THEN "*Accepted_name_family"
838
    ELSE "*Name_matched_accepted_family"
839
END$$)::util.derived_col_def);
840
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
841

    
842
to rename:
843
# rename column
844
# rename CHECK constraint
845
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
846
';
847

    
848

    
849
--
850
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
851
--
852

    
853
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
854
= CASE
855
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
856
    ELSE "*Genus_matched"
857
END
858

    
859
derived column
860

    
861
to modify expr:
862
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
863
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
864
    ELSE "*Genus_matched"
865
END$$)::util.derived_col_def);
866
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
867

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

    
874

    
875
--
876
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
877
--
878

    
879
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
880
= CASE
881
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
882
    ELSE "*Specific_epithet_matched"
883
END
884

    
885
derived column
886

    
887
to modify expr:
888
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
889
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
890
    ELSE "*Specific_epithet_matched"
891
END$$)::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

    
900

    
901
--
902
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
903
--
904

    
905
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
906
= CASE
907
    WHEN matched_has_accepted THEN "*Accepted_name_species"
908
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
909
END
910

    
911
derived column
912

    
913
to modify expr:
914
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
915
    WHEN matched_has_accepted THEN "*Accepted_name_species"
916
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
917
END$$)::util.derived_col_def);
918
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
919

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

    
926

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

    
931
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
932
= CASE
933
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
934
    ELSE "*Infraspecific_rank"
935
END
936

    
937
derived column
938

    
939
to modify expr:
940
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
941
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
942
    ELSE "*Infraspecific_rank"
943
END$$)::util.derived_col_def);
944
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
945

    
946
to rename:
947
# rename column
948
# rename CHECK constraint
949
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
950
';
951

    
952

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

    
957
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
958
= CASE
959
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
960
    ELSE "*Infraspecific_epithet_matched"
961
END
962

    
963
derived column
964

    
965
to modify expr:
966
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
967
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
968
    ELSE "*Infraspecific_epithet_matched"
969
END$$)::util.derived_col_def);
970
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
971

    
972
to rename:
973
# rename column
974
# rename CHECK constraint
975
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
976
';
977

    
978

    
979
--
980
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
981
--
982

    
983
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
984
= CASE
985
    WHEN matched_has_accepted THEN "*Accepted_name"
986
    ELSE "*Name_matched"
987
END
988

    
989
derived column
990

    
991
to modify expr:
992
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
993
    WHEN matched_has_accepted THEN "*Accepted_name"
994
    ELSE "*Name_matched"
995
END$$)::util.derived_col_def);
996
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
997

    
998
to rename:
999
# rename column
1000
# rename CHECK constraint
1001
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1002
';
1003

    
1004

    
1005
--
1006
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1007
--
1008

    
1009
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1010
= CASE
1011
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1012
    ELSE "*Name_matched_author"
1013
END
1014

    
1015
derived column
1016

    
1017
to modify expr:
1018
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1019
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1020
    ELSE "*Name_matched_author"
1021
END$$)::util.derived_col_def);
1022
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1023

    
1024
to rename:
1025
# rename column
1026
# rename CHECK constraint
1027
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1028
';
1029

    
1030

    
1031
--
1032
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1033
--
1034

    
1035
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1036
= CASE
1037
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1038
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1039
END
1040

    
1041
derived column
1042

    
1043
to modify expr:
1044
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1045
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1046
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1047
END$$)::util.derived_col_def);
1048
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1049

    
1050
to rename:
1051
# rename column
1052
# rename CHECK constraint
1053
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1054
';
1055

    
1056

    
1057
--
1058
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1059
--
1060

    
1061
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
1062
= "*Unmatched_terms"
1063

    
1064
derived column
1065

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

    
1070
to rename:
1071
# rename column
1072
# rename CHECK constraint
1073
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1074
';
1075

    
1076

    
1077
--
1078
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1079
--
1080

    
1081
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1082
= 
1083
        CASE
1084
            WHEN "*Accepted_name_rank" = ''family''::text THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1085
            WHEN "*Accepted_name_rank" = ''genus''::text THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1086
            ELSE "*Accepted_name_species"
1087
        END
1088

    
1089
derived column
1090

    
1091
to modify expr:
1092
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1093
        WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1094
        WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1095
        ELSE "*Accepted_name_species"
1096
    END$$)::util.derived_col_def);
1097
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1098

    
1099
to rename:
1100
# rename column
1101
# rename CHECK constraint
1102
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1103
';
1104

    
1105

    
1106
--
1107
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1108
--
1109

    
1110
CREATE VIEW taxon_best_match AS
1111
 SELECT taxon_match.batch,
1112
    taxon_match.match_num,
1113
    taxon_match."*Name_number",
1114
    taxon_match."*Name_submitted",
1115
    taxon_match."*Overall_score",
1116
    taxon_match."*Name_matched",
1117
    taxon_match."*Name_matched_rank",
1118
    taxon_match."*Name_score",
1119
    taxon_match."*Name_matched_author",
1120
    taxon_match."*Name_matched_url",
1121
    taxon_match."*Author_matched",
1122
    taxon_match."*Author_score",
1123
    taxon_match."*Family_matched",
1124
    taxon_match."*Family_score",
1125
    taxon_match."*Name_matched_accepted_family",
1126
    taxon_match."*Genus_matched",
1127
    taxon_match."*Genus_score",
1128
    taxon_match."*Specific_epithet_matched",
1129
    taxon_match."*Specific_epithet_score",
1130
    taxon_match."*Infraspecific_rank",
1131
    taxon_match."*Infraspecific_epithet_matched",
1132
    taxon_match."*Infraspecific_epithet_score",
1133
    taxon_match."*Infraspecific_rank_2",
1134
    taxon_match."*Infraspecific_epithet_2_matched",
1135
    taxon_match."*Infraspecific_epithet_2_score",
1136
    taxon_match."*Annotations",
1137
    taxon_match."*Unmatched_terms",
1138
    taxon_match."*Taxonomic_status",
1139
    taxon_match."*Accepted_name",
1140
    taxon_match."*Accepted_name_author",
1141
    taxon_match."*Accepted_name_rank",
1142
    taxon_match."*Accepted_name_url",
1143
    taxon_match."*Accepted_name_species",
1144
    taxon_match."*Accepted_name_family",
1145
    taxon_match."*Selected",
1146
    taxon_match."*Source",
1147
    taxon_match."*Warnings",
1148
    taxon_match."*Accepted_name_lsid",
1149
    taxon_match.is_valid_match,
1150
    taxon_match.scrubbed_unique_taxon_name,
1151
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1152
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1153
    taxon_match.matched_has_accepted,
1154
    taxon_match."__accepted_{genus,specific_epithet}",
1155
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1156
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1157
    taxon_match.__accepted_infraspecific_label,
1158
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1159
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1160
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1161
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1162
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1163
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1164
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1165
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1166
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1167
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1168
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1169
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1170
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1171
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1172
   FROM taxon_match
1173
  WHERE (taxon_match."*Selected" = 'true'::text);
1174

    
1175

    
1176
--
1177
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1178
--
1179

    
1180
COMMENT ON VIEW taxon_best_match IS '
1181
to modify:
1182
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1183
SELECT __
1184
$$);
1185
';
1186

    
1187

    
1188
--
1189
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1190
--
1191

    
1192
CREATE VIEW "MatchedTaxon" AS
1193
 SELECT taxon_best_match.batch,
1194
    taxon_best_match.match_num,
1195
    taxon_best_match."*Name_number",
1196
    taxon_best_match."*Name_submitted",
1197
    taxon_best_match."*Overall_score",
1198
    taxon_best_match."*Name_matched",
1199
    taxon_best_match."*Name_matched_rank",
1200
    taxon_best_match."*Name_score",
1201
    taxon_best_match."*Name_matched_author",
1202
    taxon_best_match."*Name_matched_url",
1203
    taxon_best_match."*Author_matched",
1204
    taxon_best_match."*Author_score",
1205
    taxon_best_match."*Family_matched",
1206
    taxon_best_match."*Family_score",
1207
    taxon_best_match."*Name_matched_accepted_family",
1208
    taxon_best_match."*Genus_matched",
1209
    taxon_best_match."*Genus_score",
1210
    taxon_best_match."*Specific_epithet_matched",
1211
    taxon_best_match."*Specific_epithet_score",
1212
    taxon_best_match."*Infraspecific_rank",
1213
    taxon_best_match."*Infraspecific_epithet_matched",
1214
    taxon_best_match."*Infraspecific_epithet_score",
1215
    taxon_best_match."*Infraspecific_rank_2",
1216
    taxon_best_match."*Infraspecific_epithet_2_matched",
1217
    taxon_best_match."*Infraspecific_epithet_2_score",
1218
    taxon_best_match."*Annotations",
1219
    taxon_best_match."*Unmatched_terms",
1220
    taxon_best_match."*Taxonomic_status",
1221
    taxon_best_match."*Accepted_name",
1222
    taxon_best_match."*Accepted_name_author",
1223
    taxon_best_match."*Accepted_name_rank",
1224
    taxon_best_match."*Accepted_name_url",
1225
    taxon_best_match."*Accepted_name_species",
1226
    taxon_best_match."*Accepted_name_family",
1227
    taxon_best_match."*Selected",
1228
    taxon_best_match."*Source",
1229
    taxon_best_match."*Warnings",
1230
    taxon_best_match."*Accepted_name_lsid",
1231
    taxon_best_match.is_valid_match,
1232
    taxon_best_match.scrubbed_unique_taxon_name,
1233
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1234
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1235
    taxon_best_match.matched_has_accepted,
1236
    taxon_best_match."__accepted_{genus,specific_epithet}",
1237
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1238
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1239
    taxon_best_match.__accepted_infraspecific_label,
1240
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1241
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1242
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1243
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1244
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1245
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1246
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1247
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1248
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1249
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1250
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1251
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1252
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1253
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1254
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1255
        CASE
1256
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1257
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1258
            ELSE taxon_best_match."*Accepted_name_species"
1259
        END AS accepted_morphospecies_binomial
1260
   FROM taxon_best_match;
1261

    
1262

    
1263
--
1264
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1265
--
1266

    
1267
COMMENT ON VIEW "MatchedTaxon" IS '
1268
to modify:
1269
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1270
SELECT __
1271
$$);
1272
';
1273

    
1274

    
1275
--
1276
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1277
--
1278

    
1279
CREATE VIEW "ValidMatchedTaxon" AS
1280
 SELECT "MatchedTaxon".batch,
1281
    "MatchedTaxon".match_num,
1282
    "MatchedTaxon"."*Name_number",
1283
    "MatchedTaxon"."*Name_submitted",
1284
    "MatchedTaxon"."*Overall_score",
1285
    "MatchedTaxon"."*Name_matched",
1286
    "MatchedTaxon"."*Name_matched_rank",
1287
    "MatchedTaxon"."*Name_score",
1288
    "MatchedTaxon"."*Name_matched_author",
1289
    "MatchedTaxon"."*Name_matched_url",
1290
    "MatchedTaxon"."*Author_matched",
1291
    "MatchedTaxon"."*Author_score",
1292
    "MatchedTaxon"."*Family_matched",
1293
    "MatchedTaxon"."*Family_score",
1294
    "MatchedTaxon"."*Name_matched_accepted_family",
1295
    "MatchedTaxon"."*Genus_matched",
1296
    "MatchedTaxon"."*Genus_score",
1297
    "MatchedTaxon"."*Specific_epithet_matched",
1298
    "MatchedTaxon"."*Specific_epithet_score",
1299
    "MatchedTaxon"."*Infraspecific_rank",
1300
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1301
    "MatchedTaxon"."*Infraspecific_epithet_score",
1302
    "MatchedTaxon"."*Infraspecific_rank_2",
1303
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1304
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1305
    "MatchedTaxon"."*Annotations",
1306
    "MatchedTaxon"."*Unmatched_terms",
1307
    "MatchedTaxon"."*Taxonomic_status",
1308
    "MatchedTaxon"."*Accepted_name",
1309
    "MatchedTaxon"."*Accepted_name_author",
1310
    "MatchedTaxon"."*Accepted_name_rank",
1311
    "MatchedTaxon"."*Accepted_name_url",
1312
    "MatchedTaxon"."*Accepted_name_species",
1313
    "MatchedTaxon"."*Accepted_name_family",
1314
    "MatchedTaxon"."*Selected",
1315
    "MatchedTaxon"."*Source",
1316
    "MatchedTaxon"."*Warnings",
1317
    "MatchedTaxon"."*Accepted_name_lsid",
1318
    "MatchedTaxon".is_valid_match,
1319
    "MatchedTaxon".scrubbed_unique_taxon_name,
1320
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1321
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1322
    "MatchedTaxon".matched_has_accepted,
1323
    "MatchedTaxon"."__accepted_{genus,specific_epithet}",
1324
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1325
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1326
    "MatchedTaxon".__accepted_infraspecific_label,
1327
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1328
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1329
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1330
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1331
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1332
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1333
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1334
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1335
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1336
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1337
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1338
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1339
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1340
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1341
    "MatchedTaxon"."taxonomicStatus",
1342
    "MatchedTaxon".accepted_morphospecies_binomial
1343
   FROM "MatchedTaxon"
1344
  WHERE "MatchedTaxon".is_valid_match;
1345

    
1346

    
1347
--
1348
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1349
--
1350

    
1351
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1352
to update, use * as the column list
1353
';
1354

    
1355

    
1356
--
1357
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1358
--
1359

    
1360
CREATE TABLE batch (
1361
    id text NOT NULL,
1362
    id_by_time text,
1363
    time_submitted timestamp with time zone DEFAULT now(),
1364
    client_version text
1365
);
1366

    
1367

    
1368
--
1369
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1370
--
1371

    
1372
CREATE TABLE batch_download_settings (
1373
    id text NOT NULL,
1374
    "E-mail" text,
1375
    "Id" text,
1376
    "Job type" text,
1377
    "Contains Id" boolean,
1378
    "Start time" text,
1379
    "Finish time" text,
1380
    "TNRS version" text,
1381
    "Sources selected" text,
1382
    "Match threshold" double precision,
1383
    "Classification" text,
1384
    "Allow partial matches?" boolean,
1385
    "Sort by source" boolean,
1386
    "Constrain by higher taxonomy" boolean
1387
);
1388

    
1389

    
1390
--
1391
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1392
--
1393

    
1394
COMMENT ON TABLE batch_download_settings IS '
1395
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1396
';
1397

    
1398

    
1399
--
1400
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1401
--
1402

    
1403
CREATE TABLE client_version (
1404
    id text NOT NULL,
1405
    global_rev integer NOT NULL,
1406
    "/lib/tnrs.py rev" integer,
1407
    "/bin/tnrs_db rev" integer
1408
);
1409

    
1410

    
1411
--
1412
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1413
--
1414

    
1415
COMMENT ON TABLE client_version IS '
1416
contains svn revisions
1417
';
1418

    
1419

    
1420
--
1421
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1422
--
1423

    
1424
COMMENT ON COLUMN client_version.global_rev IS '
1425
from `svn info .` > Last Changed Rev
1426
';
1427

    
1428

    
1429
--
1430
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1431
--
1432

    
1433
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1434
from `svn info lib/tnrs.py` > Last Changed Rev
1435
';
1436

    
1437

    
1438
--
1439
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1440
--
1441

    
1442
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1443
from `svn info bin/tnrs_db` > Last Changed Rev
1444
';
1445

    
1446

    
1447
--
1448
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1449
--
1450

    
1451
CREATE VIEW taxon_match_input AS
1452
 SELECT taxon_match."*Name_number" AS "Name_number",
1453
    taxon_match."*Name_submitted" AS "Name_submitted",
1454
    taxon_match."*Overall_score" AS "Overall_score",
1455
    taxon_match."*Name_matched" AS "Name_matched",
1456
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1457
    taxon_match."*Name_score" AS "Name_score",
1458
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1459
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1460
    taxon_match."*Author_matched" AS "Author_matched",
1461
    taxon_match."*Author_score" AS "Author_score",
1462
    taxon_match."*Family_matched" AS "Family_matched",
1463
    taxon_match."*Family_score" AS "Family_score",
1464
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1465
    taxon_match."*Genus_matched" AS "Genus_matched",
1466
    taxon_match."*Genus_score" AS "Genus_score",
1467
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1468
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1469
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1470
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1471
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1472
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1473
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1474
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1475
    taxon_match."*Annotations" AS "Annotations",
1476
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1477
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1478
    taxon_match."*Accepted_name" AS "Accepted_name",
1479
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1480
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1481
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1482
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1483
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1484
    taxon_match."*Selected" AS "Selected",
1485
    taxon_match."*Source" AS "Source",
1486
    taxon_match."*Warnings" AS "Warnings",
1487
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1488
   FROM taxon_match;
1489

    
1490

    
1491
--
1492
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1493
--
1494

    
1495
CREATE TABLE taxon_match_input__copy_to (
1496
    "Name_number" integer,
1497
    "Name_submitted" text,
1498
    "Overall_score" double precision,
1499
    "Name_matched" text,
1500
    "Name_matched_rank" text,
1501
    "Name_score" double precision,
1502
    "Name_matched_author" text,
1503
    "Name_matched_url" text,
1504
    "Author_matched" text,
1505
    "Author_score" double precision,
1506
    "Family_matched" text,
1507
    "Family_score" double precision,
1508
    "Name_matched_accepted_family" text,
1509
    "Genus_matched" text,
1510
    "Genus_score" double precision,
1511
    "Specific_epithet_matched" text,
1512
    "Specific_epithet_score" double precision,
1513
    "Infraspecific_rank" text,
1514
    "Infraspecific_epithet_matched" text,
1515
    "Infraspecific_epithet_score" double precision,
1516
    "Infraspecific_rank_2" text,
1517
    "Infraspecific_epithet_2_matched" text,
1518
    "Infraspecific_epithet_2_score" double precision,
1519
    "Annotations" text,
1520
    "Unmatched_terms" text,
1521
    "Taxonomic_status" text,
1522
    "Accepted_name" text,
1523
    "Accepted_name_author" text,
1524
    "Accepted_name_rank" text,
1525
    "Accepted_name_url" text,
1526
    "Accepted_name_species" text,
1527
    "Accepted_name_family" text,
1528
    "Selected" text,
1529
    "Source" text,
1530
    "Warnings" text,
1531
    "Accepted_name_lsid" text
1532
);
1533

    
1534

    
1535
--
1536
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1537
--
1538

    
1539
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1540
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1541
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1542
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1543
    taxon_match."*Genus_matched" AS scrubbed_genus,
1544
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1545
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1546
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1547
    taxon_match."*Name_matched_author" AS scrubbed_author,
1548
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1549
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1550
   FROM taxon_match;
1551

    
1552

    
1553
--
1554
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1555
--
1556

    
1557
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1558
to modify:
1559
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1560
SELECT __
1561
$$);
1562

    
1563
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.
1564
';
1565

    
1566

    
1567
--
1568
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1569
--
1570

    
1571
CREATE VIEW taxon_scrub AS
1572
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1573
    "ValidMatchedTaxon".batch,
1574
    "ValidMatchedTaxon".match_num,
1575
    "ValidMatchedTaxon"."*Name_number",
1576
    "ValidMatchedTaxon"."*Name_submitted",
1577
    "ValidMatchedTaxon"."*Overall_score",
1578
    "ValidMatchedTaxon"."*Name_matched",
1579
    "ValidMatchedTaxon"."*Name_matched_rank",
1580
    "ValidMatchedTaxon"."*Name_score",
1581
    "ValidMatchedTaxon"."*Name_matched_author",
1582
    "ValidMatchedTaxon"."*Name_matched_url",
1583
    "ValidMatchedTaxon"."*Author_matched",
1584
    "ValidMatchedTaxon"."*Author_score",
1585
    "ValidMatchedTaxon"."*Family_matched",
1586
    "ValidMatchedTaxon"."*Family_score",
1587
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1588
    "ValidMatchedTaxon"."*Genus_matched",
1589
    "ValidMatchedTaxon"."*Genus_score",
1590
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1591
    "ValidMatchedTaxon"."*Specific_epithet_score",
1592
    "ValidMatchedTaxon"."*Infraspecific_rank",
1593
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1594
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1595
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1596
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1597
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1598
    "ValidMatchedTaxon"."*Annotations",
1599
    "ValidMatchedTaxon"."*Unmatched_terms",
1600
    "ValidMatchedTaxon"."*Taxonomic_status",
1601
    "ValidMatchedTaxon"."*Accepted_name",
1602
    "ValidMatchedTaxon"."*Accepted_name_author",
1603
    "ValidMatchedTaxon"."*Accepted_name_rank",
1604
    "ValidMatchedTaxon"."*Accepted_name_url",
1605
    "ValidMatchedTaxon"."*Accepted_name_species",
1606
    "ValidMatchedTaxon"."*Accepted_name_family",
1607
    "ValidMatchedTaxon"."*Selected",
1608
    "ValidMatchedTaxon"."*Source",
1609
    "ValidMatchedTaxon"."*Warnings",
1610
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1611
    "ValidMatchedTaxon".is_valid_match,
1612
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1613
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1614
    "ValidMatchedTaxon".matched_has_accepted,
1615
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet}",
1616
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1617
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1618
    "ValidMatchedTaxon".__accepted_infraspecific_label,
1619
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1620
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1621
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1622
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1623
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1624
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1625
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1626
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1627
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1628
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1629
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1630
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1631
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1632
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1633
    "ValidMatchedTaxon"."taxonomicStatus",
1634
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1635
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1636
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1637
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1638
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1639
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1640
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1641
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1642
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1643
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1644
        CASE
1645
            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")
1646
            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")
1647
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1648
        END AS scrubbed_morphospecies_binomial
1649
   FROM ("ValidMatchedTaxon"
1650
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1651

    
1652

    
1653
--
1654
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1655
--
1656

    
1657
COMMENT ON VIEW taxon_scrub IS '
1658
to modify:
1659
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1660
SELECT __
1661
$$);
1662
';
1663

    
1664

    
1665
--
1666
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1667
--
1668

    
1669
ALTER TABLE ONLY batch_download_settings
1670
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1671

    
1672

    
1673
--
1674
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1675
--
1676

    
1677
ALTER TABLE ONLY batch
1678
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1679

    
1680

    
1681
--
1682
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1683
--
1684

    
1685
ALTER TABLE ONLY batch
1686
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1687

    
1688

    
1689
--
1690
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1691
--
1692

    
1693
ALTER TABLE ONLY client_version
1694
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1695

    
1696

    
1697
--
1698
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1699
--
1700

    
1701
ALTER TABLE ONLY taxon_match
1702
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1703

    
1704
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1705

    
1706

    
1707
--
1708
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1709
--
1710

    
1711
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1712

    
1713

    
1714
--
1715
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1716
--
1717

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

    
1720

    
1721
--
1722
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1723
--
1724

    
1725
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1726

    
1727

    
1728
--
1729
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1730
--
1731

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

    
1734

    
1735
--
1736
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1737
--
1738

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

    
1741

    
1742
--
1743
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1744
--
1745

    
1746
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
1747

    
1748

    
1749
--
1750
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1751
--
1752

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

    
1755

    
1756
--
1757
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
1758
--
1759

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

    
1762

    
1763
--
1764
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1765
--
1766

    
1767
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
1768

    
1769

    
1770
--
1771
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
1772
--
1773

    
1774
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();
1775

    
1776

    
1777
--
1778
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1779
--
1780

    
1781
ALTER TABLE ONLY batch
1782
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
1783

    
1784

    
1785
--
1786
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1787
--
1788

    
1789
ALTER TABLE ONLY batch_download_settings
1790
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1791

    
1792

    
1793
--
1794
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1795
--
1796

    
1797
ALTER TABLE ONLY taxon_match
1798
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1799

    
1800

    
1801
--
1802
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
1803
--
1804

    
1805
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
1806
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
1807
GRANT ALL ON SCHEMA "TNRS" TO bien;
1808
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
1809

    
1810

    
1811
--
1812
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
1813
--
1814

    
1815
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
1816
REVOKE ALL ON TABLE taxon_match FROM bien;
1817
GRANT ALL ON TABLE taxon_match TO bien;
1818
GRANT SELECT ON TABLE taxon_match TO bien_read;
1819

    
1820

    
1821
--
1822
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
1823
--
1824

    
1825
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
1826
REVOKE ALL ON TABLE taxon_best_match FROM bien;
1827
GRANT ALL ON TABLE taxon_best_match TO bien;
1828
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
1829

    
1830

    
1831
--
1832
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1833
--
1834

    
1835
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
1836
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
1837
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
1838
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
1839

    
1840

    
1841
--
1842
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1843
--
1844

    
1845
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
1846
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
1847
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
1848
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
1849

    
1850

    
1851
--
1852
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
1853
--
1854

    
1855
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
1856
REVOKE ALL ON TABLE taxon_match_input FROM bien;
1857
GRANT ALL ON TABLE taxon_match_input TO bien;
1858
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
1859

    
1860

    
1861
--
1862
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
1863
--
1864

    
1865
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
1866
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
1867
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
1868
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
1869

    
1870

    
1871
--
1872
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
1873
--
1874

    
1875
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
1876
REVOKE ALL ON TABLE taxon_scrub FROM bien;
1877
GRANT ALL ON TABLE taxon_scrub TO bien;
1878
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
1879

    
1880

    
1881
--
1882
-- PostgreSQL database dump complete
1883
--
1884

    
(7-7/9)