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

    
306

    
307
--
308
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
309
--
310

    
311
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
312
autogenerated, do not edit
313

    
314
to regenerate:
315
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
316
';
317

    
318

    
319
--
320
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
321
--
322

    
323
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
324
    LANGUAGE plpgsql
325
    AS $$
326
BEGIN
327
	IF new.match_num IS NULL THEN
328
		new.match_num = "TNRS".taxon_match__match_num__next();
329
	END IF;
330
	RETURN new;
331
END;
332
$$;
333

    
334

    
335
--
336
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
337
--
338

    
339
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
340
    LANGUAGE sql
341
    AS $$
342
SELECT nextval('pg_temp.taxon_match__match_num__seq');
343
$$;
344

    
345

    
346
--
347
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
348
--
349

    
350
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
351
    LANGUAGE plpgsql
352
    AS $$
353
BEGIN
354
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
355
	RETURN NULL;
356
END;
357
$$;
358

    
359

    
360
--
361
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
362
--
363

    
364
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
365
    LANGUAGE sql IMMUTABLE
366
    AS $_$
367
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
368
$_$;
369

    
370

    
371
--
372
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
373
--
374

    
375
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
376
    LANGUAGE sql IMMUTABLE
377
    AS $$
378
SELECT ARRAY[
379
]::text[]
380
$$;
381

    
382

    
383
SET default_tablespace = '';
384

    
385
SET default_with_oids = false;
386

    
387
--
388
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
389
--
390

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

    
525

    
526
--
527
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
528
--
529

    
530
COMMENT ON TABLE taxon_match IS '
531
whenever columns are renamed:
532
SELECT util.derived_cols_sync(''"TNRS".taxon_match'');
533

    
534
to remove columns or add columns at the end:
535
$ rm=1 inputs/.TNRS/data.sql.run
536
$ make schemas/remake
537

    
538
to add columns in the middle:
539
make the changes in inputs/.TNRS/schema.sql
540
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
541
$ make schemas/remake
542

    
543
to populate a new column:
544
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
545
UPDATE "TNRS".taxon_match SET "col" = value;
546
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
547
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
548
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
549
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
550

    
551
to add a constraint: runtime: 3 min ("173620 ms")
552
';
553

    
554

    
555
--
556
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
557
--
558

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

    
562
derived column
563

    
564
to modify expr:
565
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);
566
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
567

    
568
to rename:
569
# rename column
570
# rename CHECK constraint
571
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
572
';
573

    
574

    
575
--
576
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
577
--
578

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

    
582
derived column
583

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

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

    
594

    
595
--
596
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
597
--
598

    
599
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
600
= "*Accepted_name" IS NOT NULL
601

    
602
derived column
603

    
604
to modify expr:
605
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
606
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
607

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

    
614

    
615
--
616
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
617
--
618

    
619
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
620
= regexp_split_to_array("*Accepted_name_species", '' ''::text)
621

    
622
derived column
623

    
624
to modify expr:
625
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);
626
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
627

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

    
634

    
635
--
636
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
637
--
638

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

    
642
derived column
643

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

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

    
654

    
655
--
656
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
657
--
658

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

    
662
derived column
663

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

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

    
674

    
675
--
676
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
677
--
678

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

    
682
derived column
683

    
684
to modify expr:
685
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);
686
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
687

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

    
694

    
695
--
696
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
697
--
698

    
699
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
700
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
701

    
702
derived column
703

    
704
to modify expr:
705
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);
706
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
707

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

    
714

    
715
--
716
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
717
--
718

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

    
722
derived column
723

    
724
to modify expr:
725
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);
726
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
727

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

    
734

    
735
--
736
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
737
--
738

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

    
742
derived column
743

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

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

    
754

    
755
--
756
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
757
--
758

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

    
762
derived column
763

    
764
to modify expr:
765
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);
766
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
767

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

    
774

    
775
--
776
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
777
--
778

    
779
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
780
= CASE
781
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
782
    ELSE "*Name_matched_rank"
783
END
784

    
785
derived column
786

    
787
to modify expr:
788
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
789
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
790
    ELSE "*Name_matched_rank"
791
END$$)::util.derived_col_def);
792
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
793

    
794
to rename:
795
# rename column
796
# rename CHECK constraint
797
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
798
';
799

    
800

    
801
--
802
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
803
--
804

    
805
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
806
= CASE
807
    WHEN matched_has_accepted THEN "*Accepted_name_family"
808
    ELSE "*Name_matched_accepted_family"
809
END
810

    
811
derived column
812

    
813
to modify expr:
814
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
815
    WHEN matched_has_accepted THEN "*Accepted_name_family"
816
    ELSE "*Name_matched_accepted_family"
817
END$$)::util.derived_col_def);
818
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
819

    
820
to rename:
821
# rename column
822
# rename CHECK constraint
823
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
824
';
825

    
826

    
827
--
828
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
829
--
830

    
831
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
832
= CASE
833
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
834
    ELSE "*Genus_matched"
835
END
836

    
837
derived column
838

    
839
to modify expr:
840
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
841
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
842
    ELSE "*Genus_matched"
843
END$$)::util.derived_col_def);
844
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
845

    
846
to rename:
847
# rename column
848
# rename CHECK constraint
849
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
850
';
851

    
852

    
853
--
854
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
855
--
856

    
857
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
858
= CASE
859
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
860
    ELSE "*Specific_epithet_matched"
861
END
862

    
863
derived column
864

    
865
to modify expr:
866
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
867
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
868
    ELSE "*Specific_epithet_matched"
869
END$$)::util.derived_col_def);
870
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
871

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

    
878

    
879
--
880
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
881
--
882

    
883
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
884
= CASE
885
    WHEN matched_has_accepted THEN "*Accepted_name_species"
886
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
887
END
888

    
889
derived column
890

    
891
to modify expr:
892
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
893
    WHEN matched_has_accepted THEN "*Accepted_name_species"
894
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
895
END$$)::util.derived_col_def);
896
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
897

    
898
to rename:
899
# rename column
900
# rename CHECK constraint
901
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
902
';
903

    
904

    
905
--
906
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
907
--
908

    
909
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
910
= CASE
911
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
912
    ELSE "*Infraspecific_rank"
913
END
914

    
915
derived column
916

    
917
to modify expr:
918
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
919
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
920
    ELSE "*Infraspecific_rank"
921
END$$)::util.derived_col_def);
922
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
923

    
924
to rename:
925
# rename column
926
# rename CHECK constraint
927
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
928
';
929

    
930

    
931
--
932
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
933
--
934

    
935
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
936
= CASE
937
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
938
    ELSE "*Infraspecific_epithet_matched"
939
END
940

    
941
derived column
942

    
943
to modify expr:
944
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
945
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
946
    ELSE "*Infraspecific_epithet_matched"
947
END$$)::util.derived_col_def);
948
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
949

    
950
to rename:
951
# rename column
952
# rename CHECK constraint
953
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
954
';
955

    
956

    
957
--
958
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
959
--
960

    
961
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
962
= CASE
963
    WHEN matched_has_accepted THEN "*Accepted_name"
964
    ELSE "*Name_matched"
965
END
966

    
967
derived column
968

    
969
to modify expr:
970
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
971
    WHEN matched_has_accepted THEN "*Accepted_name"
972
    ELSE "*Name_matched"
973
END$$)::util.derived_col_def);
974
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
975

    
976
to rename:
977
# rename column
978
# rename CHECK constraint
979
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
980
';
981

    
982

    
983
--
984
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
985
--
986

    
987
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
988
= CASE
989
    WHEN matched_has_accepted THEN "*Accepted_name_author"
990
    ELSE "*Name_matched_author"
991
END
992

    
993
derived column
994

    
995
to modify expr:
996
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
997
    WHEN matched_has_accepted THEN "*Accepted_name_author"
998
    ELSE "*Name_matched_author"
999
END$$)::util.derived_col_def);
1000
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1001

    
1002
to rename:
1003
# rename column
1004
# rename CHECK constraint
1005
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1006
';
1007

    
1008

    
1009
--
1010
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1011
--
1012

    
1013
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1014
= CASE
1015
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1016
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1017
END
1018

    
1019
derived column
1020

    
1021
to modify expr:
1022
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1023
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1024
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1025
END$$)::util.derived_col_def);
1026
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1027

    
1028
to rename:
1029
# rename column
1030
# rename CHECK constraint
1031
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1032
';
1033

    
1034

    
1035
--
1036
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1037
--
1038

    
1039
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
1040
= "*Unmatched_terms"
1041

    
1042
derived column
1043

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

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

    
1054

    
1055
--
1056
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1057
--
1058

    
1059
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1060
= CASE
1061
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1062
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1063
    ELSE "*Accepted_name_species"
1064
END
1065

    
1066
derived column
1067

    
1068
to modify expr:
1069
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1070
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1071
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1072
    ELSE "*Accepted_name_species"
1073
END$$)::util.derived_col_def);
1074
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1075

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

    
1082

    
1083
--
1084
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1085
--
1086

    
1087
CREATE VIEW taxon_best_match AS
1088
 SELECT taxon_match.batch,
1089
    taxon_match.match_num,
1090
    taxon_match."*Name_number",
1091
    taxon_match."*Name_submitted",
1092
    taxon_match."*Overall_score",
1093
    taxon_match."*Name_matched",
1094
    taxon_match."*Name_matched_rank",
1095
    taxon_match."*Name_score",
1096
    taxon_match."*Name_matched_author",
1097
    taxon_match."*Name_matched_url",
1098
    taxon_match."*Author_matched",
1099
    taxon_match."*Author_score",
1100
    taxon_match."*Family_matched",
1101
    taxon_match."*Family_score",
1102
    taxon_match."*Name_matched_accepted_family",
1103
    taxon_match."*Genus_matched",
1104
    taxon_match."*Genus_score",
1105
    taxon_match."*Specific_epithet_matched",
1106
    taxon_match."*Specific_epithet_score",
1107
    taxon_match."*Infraspecific_rank",
1108
    taxon_match."*Infraspecific_epithet_matched",
1109
    taxon_match."*Infraspecific_epithet_score",
1110
    taxon_match."*Infraspecific_rank_2",
1111
    taxon_match."*Infraspecific_epithet_2_matched",
1112
    taxon_match."*Infraspecific_epithet_2_score",
1113
    taxon_match."*Annotations",
1114
    taxon_match."*Unmatched_terms",
1115
    taxon_match."*Taxonomic_status",
1116
    taxon_match."*Accepted_name",
1117
    taxon_match."*Accepted_name_author",
1118
    taxon_match."*Accepted_name_rank",
1119
    taxon_match."*Accepted_name_url",
1120
    taxon_match."*Accepted_name_species",
1121
    taxon_match."*Accepted_name_family",
1122
    taxon_match."*Selected",
1123
    taxon_match."*Source",
1124
    taxon_match."*Warnings",
1125
    taxon_match."*Accepted_name_lsid",
1126
    taxon_match.is_valid_match,
1127
    taxon_match.scrubbed_unique_taxon_name,
1128
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1129
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1130
    taxon_match.matched_has_accepted,
1131
    taxon_match."__accepted_{genus,specific_epithet}",
1132
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1133
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1134
    taxon_match.__accepted_infraspecific_label,
1135
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1136
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1137
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1138
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1139
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1140
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1141
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1142
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1143
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1144
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1145
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1146
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1147
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1148
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1149
   FROM taxon_match
1150
  WHERE (taxon_match."*Selected" = 'true'::text);
1151

    
1152

    
1153
--
1154
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1155
--
1156

    
1157
COMMENT ON VIEW taxon_best_match IS '
1158
to modify:
1159
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1160
SELECT __
1161
$$);
1162
';
1163

    
1164

    
1165
--
1166
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1167
--
1168

    
1169
CREATE VIEW "MatchedTaxon" AS
1170
 SELECT taxon_best_match.batch,
1171
    taxon_best_match.match_num,
1172
    taxon_best_match."*Name_number",
1173
    taxon_best_match."*Name_submitted",
1174
    taxon_best_match."*Overall_score",
1175
    taxon_best_match."*Name_matched",
1176
    taxon_best_match."*Name_matched_rank",
1177
    taxon_best_match."*Name_score",
1178
    taxon_best_match."*Name_matched_author",
1179
    taxon_best_match."*Name_matched_url",
1180
    taxon_best_match."*Author_matched",
1181
    taxon_best_match."*Author_score",
1182
    taxon_best_match."*Family_matched",
1183
    taxon_best_match."*Family_score",
1184
    taxon_best_match."*Name_matched_accepted_family",
1185
    taxon_best_match."*Genus_matched",
1186
    taxon_best_match."*Genus_score",
1187
    taxon_best_match."*Specific_epithet_matched",
1188
    taxon_best_match."*Specific_epithet_score",
1189
    taxon_best_match."*Infraspecific_rank",
1190
    taxon_best_match."*Infraspecific_epithet_matched",
1191
    taxon_best_match."*Infraspecific_epithet_score",
1192
    taxon_best_match."*Infraspecific_rank_2",
1193
    taxon_best_match."*Infraspecific_epithet_2_matched",
1194
    taxon_best_match."*Infraspecific_epithet_2_score",
1195
    taxon_best_match."*Annotations",
1196
    taxon_best_match."*Unmatched_terms",
1197
    taxon_best_match."*Taxonomic_status",
1198
    taxon_best_match."*Accepted_name",
1199
    taxon_best_match."*Accepted_name_author",
1200
    taxon_best_match."*Accepted_name_rank",
1201
    taxon_best_match."*Accepted_name_url",
1202
    taxon_best_match."*Accepted_name_species",
1203
    taxon_best_match."*Accepted_name_family",
1204
    taxon_best_match."*Selected",
1205
    taxon_best_match."*Source",
1206
    taxon_best_match."*Warnings",
1207
    taxon_best_match."*Accepted_name_lsid",
1208
    taxon_best_match.is_valid_match,
1209
    taxon_best_match.scrubbed_unique_taxon_name,
1210
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1211
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1212
    taxon_best_match.matched_has_accepted,
1213
    taxon_best_match."__accepted_{genus,specific_epithet}",
1214
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1215
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1216
    taxon_best_match.__accepted_infraspecific_label,
1217
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1218
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1219
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1220
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1221
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1222
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1223
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1224
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1225
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1226
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1227
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1228
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1229
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1230
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1231
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1232
        CASE
1233
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1234
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1235
            ELSE taxon_best_match."*Accepted_name_species"
1236
        END AS accepted_morphospecies_binomial
1237
   FROM taxon_best_match;
1238

    
1239

    
1240
--
1241
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1242
--
1243

    
1244
COMMENT ON VIEW "MatchedTaxon" IS '
1245
to modify:
1246
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1247
SELECT __
1248
$$);
1249
';
1250

    
1251

    
1252
--
1253
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1254
--
1255

    
1256
CREATE VIEW "ValidMatchedTaxon" AS
1257
 SELECT "MatchedTaxon".batch,
1258
    "MatchedTaxon".match_num,
1259
    "MatchedTaxon"."*Name_number",
1260
    "MatchedTaxon"."*Name_submitted",
1261
    "MatchedTaxon"."*Overall_score",
1262
    "MatchedTaxon"."*Name_matched",
1263
    "MatchedTaxon"."*Name_matched_rank",
1264
    "MatchedTaxon"."*Name_score",
1265
    "MatchedTaxon"."*Name_matched_author",
1266
    "MatchedTaxon"."*Name_matched_url",
1267
    "MatchedTaxon"."*Author_matched",
1268
    "MatchedTaxon"."*Author_score",
1269
    "MatchedTaxon"."*Family_matched",
1270
    "MatchedTaxon"."*Family_score",
1271
    "MatchedTaxon"."*Name_matched_accepted_family",
1272
    "MatchedTaxon"."*Genus_matched",
1273
    "MatchedTaxon"."*Genus_score",
1274
    "MatchedTaxon"."*Specific_epithet_matched",
1275
    "MatchedTaxon"."*Specific_epithet_score",
1276
    "MatchedTaxon"."*Infraspecific_rank",
1277
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1278
    "MatchedTaxon"."*Infraspecific_epithet_score",
1279
    "MatchedTaxon"."*Infraspecific_rank_2",
1280
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1281
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1282
    "MatchedTaxon"."*Annotations",
1283
    "MatchedTaxon"."*Unmatched_terms",
1284
    "MatchedTaxon"."*Taxonomic_status",
1285
    "MatchedTaxon"."*Accepted_name",
1286
    "MatchedTaxon"."*Accepted_name_author",
1287
    "MatchedTaxon"."*Accepted_name_rank",
1288
    "MatchedTaxon"."*Accepted_name_url",
1289
    "MatchedTaxon"."*Accepted_name_species",
1290
    "MatchedTaxon"."*Accepted_name_family",
1291
    "MatchedTaxon"."*Selected",
1292
    "MatchedTaxon"."*Source",
1293
    "MatchedTaxon"."*Warnings",
1294
    "MatchedTaxon"."*Accepted_name_lsid",
1295
    "MatchedTaxon".is_valid_match,
1296
    "MatchedTaxon".scrubbed_unique_taxon_name,
1297
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1298
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1299
    "MatchedTaxon".matched_has_accepted,
1300
    "MatchedTaxon"."__accepted_{genus,specific_epithet}",
1301
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1302
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1303
    "MatchedTaxon".__accepted_infraspecific_label,
1304
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1305
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1306
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1307
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1308
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1309
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1310
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1311
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1312
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1313
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1314
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1315
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1316
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1317
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1318
    "MatchedTaxon"."taxonomicStatus",
1319
    "MatchedTaxon".accepted_morphospecies_binomial
1320
   FROM "MatchedTaxon"
1321
  WHERE "MatchedTaxon".is_valid_match;
1322

    
1323

    
1324
--
1325
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1326
--
1327

    
1328
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1329
to update, use * as the column list
1330
';
1331

    
1332

    
1333
--
1334
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1335
--
1336

    
1337
CREATE TABLE batch (
1338
    id text NOT NULL,
1339
    id_by_time text,
1340
    time_submitted timestamp with time zone DEFAULT now(),
1341
    client_version text
1342
);
1343

    
1344

    
1345
--
1346
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1347
--
1348

    
1349
CREATE TABLE batch_download_settings (
1350
    id text NOT NULL,
1351
    "E-mail" text,
1352
    "Id" text,
1353
    "Job type" text,
1354
    "Contains Id" boolean,
1355
    "Start time" text,
1356
    "Finish time" text,
1357
    "TNRS version" text,
1358
    "Sources selected" text,
1359
    "Match threshold" double precision,
1360
    "Classification" text,
1361
    "Allow partial matches?" boolean,
1362
    "Sort by source" boolean,
1363
    "Constrain by higher taxonomy" boolean
1364
);
1365

    
1366

    
1367
--
1368
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1369
--
1370

    
1371
COMMENT ON TABLE batch_download_settings IS '
1372
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1373
';
1374

    
1375

    
1376
--
1377
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1378
--
1379

    
1380
CREATE TABLE client_version (
1381
    id text NOT NULL,
1382
    global_rev integer NOT NULL,
1383
    "/lib/tnrs.py rev" integer,
1384
    "/bin/tnrs_db rev" integer
1385
);
1386

    
1387

    
1388
--
1389
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1390
--
1391

    
1392
COMMENT ON TABLE client_version IS '
1393
contains svn revisions
1394
';
1395

    
1396

    
1397
--
1398
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1399
--
1400

    
1401
COMMENT ON COLUMN client_version.global_rev IS '
1402
from `svn info .` > Last Changed Rev
1403
';
1404

    
1405

    
1406
--
1407
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1408
--
1409

    
1410
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1411
from `svn info lib/tnrs.py` > Last Changed Rev
1412
';
1413

    
1414

    
1415
--
1416
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1417
--
1418

    
1419
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1420
from `svn info bin/tnrs_db` > Last Changed Rev
1421
';
1422

    
1423

    
1424
--
1425
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1426
--
1427

    
1428
CREATE VIEW taxon_match_input AS
1429
 SELECT taxon_match."*Name_number" AS "Name_number",
1430
    taxon_match."*Name_submitted" AS "Name_submitted",
1431
    taxon_match."*Overall_score" AS "Overall_score",
1432
    taxon_match."*Name_matched" AS "Name_matched",
1433
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1434
    taxon_match."*Name_score" AS "Name_score",
1435
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1436
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1437
    taxon_match."*Author_matched" AS "Author_matched",
1438
    taxon_match."*Author_score" AS "Author_score",
1439
    taxon_match."*Family_matched" AS "Family_matched",
1440
    taxon_match."*Family_score" AS "Family_score",
1441
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1442
    taxon_match."*Genus_matched" AS "Genus_matched",
1443
    taxon_match."*Genus_score" AS "Genus_score",
1444
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1445
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1446
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1447
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1448
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1449
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1450
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1451
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1452
    taxon_match."*Annotations" AS "Annotations",
1453
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1454
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1455
    taxon_match."*Accepted_name" AS "Accepted_name",
1456
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1457
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1458
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1459
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1460
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1461
    taxon_match."*Selected" AS "Selected",
1462
    taxon_match."*Source" AS "Source",
1463
    taxon_match."*Warnings" AS "Warnings",
1464
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1465
   FROM taxon_match;
1466

    
1467

    
1468
--
1469
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1470
--
1471

    
1472
CREATE TABLE taxon_match_input__copy_to (
1473
    "Name_number" integer,
1474
    "Name_submitted" text,
1475
    "Overall_score" double precision,
1476
    "Name_matched" text,
1477
    "Name_matched_rank" text,
1478
    "Name_score" double precision,
1479
    "Name_matched_author" text,
1480
    "Name_matched_url" text,
1481
    "Author_matched" text,
1482
    "Author_score" double precision,
1483
    "Family_matched" text,
1484
    "Family_score" double precision,
1485
    "Name_matched_accepted_family" text,
1486
    "Genus_matched" text,
1487
    "Genus_score" double precision,
1488
    "Specific_epithet_matched" text,
1489
    "Specific_epithet_score" double precision,
1490
    "Infraspecific_rank" text,
1491
    "Infraspecific_epithet_matched" text,
1492
    "Infraspecific_epithet_score" double precision,
1493
    "Infraspecific_rank_2" text,
1494
    "Infraspecific_epithet_2_matched" text,
1495
    "Infraspecific_epithet_2_score" double precision,
1496
    "Annotations" text,
1497
    "Unmatched_terms" text,
1498
    "Taxonomic_status" text,
1499
    "Accepted_name" text,
1500
    "Accepted_name_author" text,
1501
    "Accepted_name_rank" text,
1502
    "Accepted_name_url" text,
1503
    "Accepted_name_species" text,
1504
    "Accepted_name_family" text,
1505
    "Selected" text,
1506
    "Source" text,
1507
    "Warnings" text,
1508
    "Accepted_name_lsid" text
1509
);
1510

    
1511

    
1512
--
1513
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1514
--
1515

    
1516
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1517
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1518
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1519
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1520
    taxon_match."*Genus_matched" AS scrubbed_genus,
1521
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1522
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1523
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1524
    taxon_match."*Name_matched_author" AS scrubbed_author,
1525
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1526
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1527
   FROM taxon_match;
1528

    
1529

    
1530
--
1531
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1532
--
1533

    
1534
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1535
to modify:
1536
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1537
SELECT __
1538
$$);
1539

    
1540
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.
1541
';
1542

    
1543

    
1544
--
1545
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1546
--
1547

    
1548
CREATE VIEW taxon_scrub AS
1549
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1550
    "ValidMatchedTaxon".batch,
1551
    "ValidMatchedTaxon".match_num,
1552
    "ValidMatchedTaxon"."*Name_number",
1553
    "ValidMatchedTaxon"."*Name_submitted",
1554
    "ValidMatchedTaxon"."*Overall_score",
1555
    "ValidMatchedTaxon"."*Name_matched",
1556
    "ValidMatchedTaxon"."*Name_matched_rank",
1557
    "ValidMatchedTaxon"."*Name_score",
1558
    "ValidMatchedTaxon"."*Name_matched_author",
1559
    "ValidMatchedTaxon"."*Name_matched_url",
1560
    "ValidMatchedTaxon"."*Author_matched",
1561
    "ValidMatchedTaxon"."*Author_score",
1562
    "ValidMatchedTaxon"."*Family_matched",
1563
    "ValidMatchedTaxon"."*Family_score",
1564
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1565
    "ValidMatchedTaxon"."*Genus_matched",
1566
    "ValidMatchedTaxon"."*Genus_score",
1567
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1568
    "ValidMatchedTaxon"."*Specific_epithet_score",
1569
    "ValidMatchedTaxon"."*Infraspecific_rank",
1570
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1571
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1572
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1573
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1574
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1575
    "ValidMatchedTaxon"."*Annotations",
1576
    "ValidMatchedTaxon"."*Unmatched_terms",
1577
    "ValidMatchedTaxon"."*Taxonomic_status",
1578
    "ValidMatchedTaxon"."*Accepted_name",
1579
    "ValidMatchedTaxon"."*Accepted_name_author",
1580
    "ValidMatchedTaxon"."*Accepted_name_rank",
1581
    "ValidMatchedTaxon"."*Accepted_name_url",
1582
    "ValidMatchedTaxon"."*Accepted_name_species",
1583
    "ValidMatchedTaxon"."*Accepted_name_family",
1584
    "ValidMatchedTaxon"."*Selected",
1585
    "ValidMatchedTaxon"."*Source",
1586
    "ValidMatchedTaxon"."*Warnings",
1587
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1588
    "ValidMatchedTaxon".is_valid_match,
1589
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1590
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1591
    "ValidMatchedTaxon".matched_has_accepted,
1592
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet}",
1593
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1594
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1595
    "ValidMatchedTaxon".__accepted_infraspecific_label,
1596
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1597
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1598
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1599
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1600
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1601
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1602
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1603
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1604
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1605
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1606
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1607
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1608
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1609
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1610
    "ValidMatchedTaxon"."taxonomicStatus",
1611
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1612
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1613
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1614
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1615
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1616
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1617
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1618
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1619
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1620
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1621
        CASE
1622
            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")
1623
            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")
1624
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1625
        END AS scrubbed_morphospecies_binomial
1626
   FROM ("ValidMatchedTaxon"
1627
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1628

    
1629

    
1630
--
1631
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1632
--
1633

    
1634
COMMENT ON VIEW taxon_scrub IS '
1635
to modify:
1636
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1637
SELECT __
1638
$$);
1639
';
1640

    
1641

    
1642
--
1643
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1644
--
1645

    
1646
ALTER TABLE ONLY batch_download_settings
1647
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1648

    
1649

    
1650
--
1651
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1652
--
1653

    
1654
ALTER TABLE ONLY batch
1655
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1656

    
1657

    
1658
--
1659
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1660
--
1661

    
1662
ALTER TABLE ONLY batch
1663
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1664

    
1665

    
1666
--
1667
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1668
--
1669

    
1670
ALTER TABLE ONLY client_version
1671
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1672

    
1673

    
1674
--
1675
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1676
--
1677

    
1678
ALTER TABLE ONLY taxon_match
1679
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1680

    
1681
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1682

    
1683

    
1684
--
1685
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1686
--
1687

    
1688
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1689

    
1690

    
1691
--
1692
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1693
--
1694

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

    
1697

    
1698
--
1699
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1700
--
1701

    
1702
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1703

    
1704

    
1705
--
1706
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1707
--
1708

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

    
1711

    
1712
--
1713
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1714
--
1715

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

    
1718

    
1719
--
1720
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1721
--
1722

    
1723
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
1724

    
1725

    
1726
--
1727
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1728
--
1729

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

    
1732

    
1733
--
1734
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
1735
--
1736

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

    
1739

    
1740
--
1741
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1742
--
1743

    
1744
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
1745

    
1746

    
1747
--
1748
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
1749
--
1750

    
1751
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();
1752

    
1753

    
1754
--
1755
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1756
--
1757

    
1758
ALTER TABLE ONLY batch
1759
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
1760

    
1761

    
1762
--
1763
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1764
--
1765

    
1766
ALTER TABLE ONLY batch_download_settings
1767
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1768

    
1769

    
1770
--
1771
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1772
--
1773

    
1774
ALTER TABLE ONLY taxon_match
1775
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1776

    
1777

    
1778
--
1779
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
1780
--
1781

    
1782
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
1783
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
1784
GRANT ALL ON SCHEMA "TNRS" TO bien;
1785
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
1786

    
1787

    
1788
--
1789
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
1790
--
1791

    
1792
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
1793
REVOKE ALL ON TABLE taxon_match FROM bien;
1794
GRANT ALL ON TABLE taxon_match TO bien;
1795
GRANT SELECT ON TABLE taxon_match TO bien_read;
1796

    
1797

    
1798
--
1799
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
1800
--
1801

    
1802
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
1803
REVOKE ALL ON TABLE taxon_best_match FROM bien;
1804
GRANT ALL ON TABLE taxon_best_match TO bien;
1805
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
1806

    
1807

    
1808
--
1809
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1810
--
1811

    
1812
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
1813
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
1814
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
1815
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
1816

    
1817

    
1818
--
1819
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1820
--
1821

    
1822
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
1823
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
1824
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
1825
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
1826

    
1827

    
1828
--
1829
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
1830
--
1831

    
1832
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
1833
REVOKE ALL ON TABLE taxon_match_input FROM bien;
1834
GRANT ALL ON TABLE taxon_match_input TO bien;
1835
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
1836

    
1837

    
1838
--
1839
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
1840
--
1841

    
1842
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
1843
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
1844
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
1845
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
1846

    
1847

    
1848
--
1849
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
1850
--
1851

    
1852
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
1853
REVOKE ALL ON TABLE taxon_scrub FROM bien;
1854
GRANT ALL ON TABLE taxon_scrub TO bien;
1855
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
1856

    
1857

    
1858
--
1859
-- PostgreSQL database dump complete
1860
--
1861

    
(7-7/9)