Project

General

Profile

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

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

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

    
16
--CREATE SCHEMA "TNRS";
17

    
18

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

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

    
41

    
42
SET search_path = "TNRS", pg_catalog;
43

    
44
--
45
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
46
--
47

    
48
CREATE FUNCTION batch__fill() RETURNS trigger
49
    LANGUAGE plpgsql
50
    AS $$
51
BEGIN
52
	new.id_by_time = new.time_submitted;
53
	new.id = COALESCE(new.id, new.id_by_time);
54
	RETURN new;
55
END;
56
$$;
57

    
58

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

    
63
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
64
    LANGUAGE sql STABLE STRICT
65
    AS $_$
66
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
67
$_$;
68

    
69

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

    
74
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
75
    LANGUAGE sql STABLE STRICT
76
    AS $_$
77
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
78
$_$;
79

    
80

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

    
85
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
86
    LANGUAGE sql IMMUTABLE
87
    AS $_$
88
/* from http://wiki.vegpath.org/2013-11-14_conference_call#taxonomic-fields:
89
"taxonomic_status should be accepted instead of synonym when an accepted name is
90
available (this is not always the case when a name is marked as a synonym)" */
91
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
92
$_$;
93

    
94

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

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

    
105

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

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

    
114

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

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

    
128

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

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

    
196

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

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

    
209

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

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

    
322

    
323
--
324
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
325
--
326

    
327
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
328
autogenerated, do not edit
329

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

    
334

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

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

    
350

    
351
--
352
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
353
--
354

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

    
361

    
362
--
363
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
364
--
365

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

    
375

    
376
--
377
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
378
--
379

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

    
386

    
387
--
388
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
389
--
390

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

    
398

    
399
SET default_tablespace = '';
400

    
401
SET default_with_oids = false;
402

    
403
--
404
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
405
--
406

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

    
558

    
559
--
560
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
561
--
562

    
563
COMMENT ON TABLE taxon_match IS '
564
whenever columns are renamed:
565
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
566

    
567
to port derived column changes to vegbiendev:
568
SELECT util.derived_cols_export(''"TNRS".taxon_match'');
569
# run the returned SQL on vegbiendev
570
	-- runtime: 6 h, 2.6 ms/row ("22030570 ms"; "rows=8353235")
571
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
572

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

    
581
to remove a derived column:
582
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''col''));
583
$ make schemas/remake
584

    
585
to remove a non-derived column:
586
SELECT util.drop_column((''"TNRS".taxon_match'', ''col''));
587
$ make schemas/remake
588

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

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

    
600

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

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

    
608
derived column
609

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

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

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

    
624

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

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

    
632
derived column
633

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

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

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

    
648

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

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

    
656
derived column
657

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

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

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

    
672

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

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

    
680
derived column
681

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

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

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

    
696

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

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

    
704
derived column
705

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

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

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

    
720

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

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

    
732
derived column
733

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

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

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

    
752

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

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

    
760
derived column
761

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

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

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

    
776

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

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

    
784
derived column
785

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

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

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

    
800

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

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

    
808
derived column
809

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

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

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

    
824

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

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

    
832
derived column
833

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

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

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

    
848

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

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

    
860
derived column
861

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

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

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

    
880

    
881
--
882
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
883
--
884

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

    
888
derived column
889

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

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

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

    
904

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

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

    
912
derived column
913

    
914
to modify expr:
915
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);
916
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
917

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

    
923
to drop:
924
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
925
	-- DROP __ CASCADE doesn''t work when there are dependent views
926
';
927

    
928

    
929
--
930
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
931
--
932

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

    
936
derived column
937

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

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

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

    
952

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

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

    
960
derived column
961

    
962
to modify expr:
963
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);
964
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
965

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

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

    
976

    
977
--
978
-- Name: COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
979
--
980

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

    
984
derived column
985

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

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

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

    
1000

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

    
1005
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
1006
= CASE
1007
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1008
    ELSE "*Name_matched_rank"
1009
END
1010

    
1011
derived column
1012

    
1013
to modify expr:
1014
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
1015
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1016
    ELSE "*Name_matched_rank"
1017
END$$)::util.derived_col_def);
1018
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1019

    
1020
to rename:
1021
# rename column
1022
# rename CHECK constraint
1023
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1024

    
1025
to drop:
1026
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col);
1027
	-- DROP __ CASCADE doesn''t work when there are dependent views
1028
';
1029

    
1030

    
1031
--
1032
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1033
--
1034

    
1035
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1036
= CASE
1037
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1038
    ELSE "*Name_matched_accepted_family"
1039
END
1040

    
1041
derived column
1042

    
1043
to modify expr:
1044
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1045
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1046
    ELSE "*Name_matched_accepted_family"
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
to drop:
1056
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1057
	-- DROP __ CASCADE doesn''t work when there are dependent views
1058
';
1059

    
1060

    
1061
--
1062
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1063
--
1064

    
1065
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
1066
= CASE
1067
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1068
    ELSE "*Genus_matched"
1069
END
1070

    
1071
derived column
1072

    
1073
to modify expr:
1074
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
1075
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1076
    ELSE "*Genus_matched"
1077
END$$)::util.derived_col_def);
1078
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1079

    
1080
to rename:
1081
# rename column
1082
# rename CHECK constraint
1083
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1084

    
1085
to drop:
1086
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col);
1087
	-- DROP __ CASCADE doesn''t work when there are dependent views
1088
';
1089

    
1090

    
1091
--
1092
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1093
--
1094

    
1095
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
1096
= CASE
1097
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1098
    ELSE "*Specific_epithet_matched"
1099
END
1100

    
1101
derived column
1102

    
1103
to modify expr:
1104
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1105
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1106
    ELSE "*Specific_epithet_matched"
1107
END$$)::util.derived_col_def);
1108
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1109

    
1110
to rename:
1111
# rename column
1112
# rename CHECK constraint
1113
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1114

    
1115
to drop:
1116
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col);
1117
	-- DROP __ CASCADE doesn''t work when there are dependent views
1118
';
1119

    
1120

    
1121
--
1122
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1123
--
1124

    
1125
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1126
= CASE
1127
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1128
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1129
END
1130

    
1131
derived column
1132

    
1133
to modify expr:
1134
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1135
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1136
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1137
END$$)::util.derived_col_def);
1138
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1139

    
1140
to rename:
1141
# rename column
1142
# rename CHECK constraint
1143
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1144

    
1145
to drop:
1146
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1147
	-- DROP __ CASCADE doesn''t work when there are dependent views
1148
';
1149

    
1150

    
1151
--
1152
-- Name: COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1153
--
1154

    
1155
COMMENT ON COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1156
= CASE
1157
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1158
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1159
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1160
END
1161

    
1162
derived column
1163

    
1164
to modify expr:
1165
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1166
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1167
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1168
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1169
END$$)::util.derived_col_def);
1170
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1171

    
1172
to rename:
1173
# rename column
1174
# rename CHECK constraint
1175
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1176

    
1177
to drop:
1178
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col);
1179
	-- DROP __ CASCADE doesn''t work when there are dependent views
1180
';
1181

    
1182

    
1183
--
1184
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1185
--
1186

    
1187
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
1188
= CASE
1189
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1190
    ELSE "*Infraspecific_rank"
1191
END
1192

    
1193
derived column
1194

    
1195
to modify expr:
1196
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
1197
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1198
    ELSE "*Infraspecific_rank"
1199
END$$)::util.derived_col_def);
1200
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1201

    
1202
to rename:
1203
# rename column
1204
# rename CHECK constraint
1205
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1206

    
1207
to drop:
1208
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
1209
	-- DROP __ CASCADE doesn''t work when there are dependent views
1210
';
1211

    
1212

    
1213
--
1214
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1215
--
1216

    
1217
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
1218
= CASE
1219
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1220
    ELSE "*Infraspecific_epithet_matched"
1221
END
1222

    
1223
derived column
1224

    
1225
to modify expr:
1226
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1227
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1228
    ELSE "*Infraspecific_epithet_matched"
1229
END$$)::util.derived_col_def);
1230
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1231

    
1232
to rename:
1233
# rename column
1234
# rename CHECK constraint
1235
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1236

    
1237
to drop:
1238
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col);
1239
	-- DROP __ CASCADE doesn''t work when there are dependent views
1240
';
1241

    
1242

    
1243
--
1244
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1245
--
1246

    
1247
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1248
= CASE
1249
    WHEN matched_has_accepted THEN "*Accepted_name"
1250
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1251
END
1252

    
1253
derived column
1254

    
1255
to modify expr:
1256
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1257
    WHEN matched_has_accepted THEN "*Accepted_name"
1258
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1259
END$$)::util.derived_col_def);
1260
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1261

    
1262
to rename:
1263
# rename column
1264
# rename CHECK constraint
1265
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1266

    
1267
to drop:
1268
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1269
	-- DROP __ CASCADE doesn''t work when there are dependent views
1270
';
1271

    
1272

    
1273
--
1274
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1275
--
1276

    
1277
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1278
= CASE
1279
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1280
    ELSE "*Name_matched_author"
1281
END
1282

    
1283
derived column
1284

    
1285
to modify expr:
1286
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1287
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1288
    ELSE "*Name_matched_author"
1289
END$$)::util.derived_col_def);
1290
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1291

    
1292
to rename:
1293
# rename column
1294
# rename CHECK constraint
1295
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1296

    
1297
to drop:
1298
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1299
	-- DROP __ CASCADE doesn''t work when there are dependent views
1300
';
1301

    
1302

    
1303
--
1304
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1305
--
1306

    
1307
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1308
= CASE
1309
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1310
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1311
END
1312

    
1313
derived column
1314

    
1315
to modify expr:
1316
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1317
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1318
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1319
END$$)::util.derived_col_def);
1320
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1321

    
1322
to rename:
1323
# rename column
1324
# rename CHECK constraint
1325
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1326

    
1327
to drop:
1328
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
1329
	-- DROP __ CASCADE doesn''t work when there are dependent views
1330
';
1331

    
1332

    
1333
--
1334
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1335
--
1336

    
1337
CREATE VIEW taxon_best_match AS
1338
 SELECT taxon_match.batch,
1339
    taxon_match.match_num,
1340
    taxon_match."*Name_number",
1341
    taxon_match."*Name_submitted",
1342
    taxon_match."*Overall_score",
1343
    taxon_match."*Name_matched",
1344
    taxon_match."*Name_matched_rank",
1345
    taxon_match."*Name_score",
1346
    taxon_match."*Name_matched_author",
1347
    taxon_match."*Name_matched_url",
1348
    taxon_match."*Author_matched",
1349
    taxon_match."*Author_score",
1350
    taxon_match."*Family_matched",
1351
    taxon_match."*Family_score",
1352
    taxon_match."*Name_matched_accepted_family",
1353
    taxon_match."*Genus_matched",
1354
    taxon_match."*Genus_score",
1355
    taxon_match."*Specific_epithet_matched",
1356
    taxon_match."*Specific_epithet_score",
1357
    taxon_match."*Infraspecific_rank",
1358
    taxon_match."*Infraspecific_epithet_matched",
1359
    taxon_match."*Infraspecific_epithet_score",
1360
    taxon_match."*Infraspecific_rank_2",
1361
    taxon_match."*Infraspecific_epithet_2_matched",
1362
    taxon_match."*Infraspecific_epithet_2_score",
1363
    taxon_match."*Annotations",
1364
    taxon_match."*Unmatched_terms",
1365
    taxon_match."*Taxonomic_status",
1366
    taxon_match."*Accepted_name",
1367
    taxon_match."*Accepted_name_author",
1368
    taxon_match."*Accepted_name_rank",
1369
    taxon_match."*Accepted_name_url",
1370
    taxon_match."*Accepted_name_species",
1371
    taxon_match."*Accepted_name_family",
1372
    taxon_match."*Selected",
1373
    taxon_match."*Source",
1374
    taxon_match."*Warnings",
1375
    taxon_match."*Accepted_name_lsid",
1376
    taxon_match.is_valid_match,
1377
    taxon_match.scrubbed_unique_taxon_name,
1378
    taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1379
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1380
    taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1381
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1382
    taxon_match.matched_has_accepted,
1383
    taxon_match."Accepted_family__@TNRS__@vegpath.org",
1384
    taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1385
    taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1386
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1387
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1388
    taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1389
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1390
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1391
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1392
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1393
    taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1394
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1395
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1396
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1397
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1398
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1399
    taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1400
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1401
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1402
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1403
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1404
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1405
   FROM taxon_match
1406
  WHERE (taxon_match."*Selected" = 'true'::text);
1407

    
1408

    
1409
--
1410
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1411
--
1412

    
1413
COMMENT ON VIEW taxon_best_match IS '
1414
to modify:
1415
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1416
SELECT __
1417
$$);
1418
';
1419

    
1420

    
1421
--
1422
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1423
--
1424

    
1425
CREATE VIEW "MatchedTaxon" AS
1426
 SELECT taxon_best_match.batch,
1427
    taxon_best_match.match_num,
1428
    taxon_best_match."*Name_number",
1429
    taxon_best_match."*Name_submitted",
1430
    taxon_best_match."*Overall_score",
1431
    taxon_best_match."*Name_matched",
1432
    taxon_best_match."*Name_matched_rank",
1433
    taxon_best_match."*Name_score",
1434
    taxon_best_match."*Name_matched_author",
1435
    taxon_best_match."*Name_matched_url",
1436
    taxon_best_match."*Author_matched",
1437
    taxon_best_match."*Author_score",
1438
    taxon_best_match."*Family_matched",
1439
    taxon_best_match."*Family_score",
1440
    taxon_best_match."*Name_matched_accepted_family",
1441
    taxon_best_match."*Genus_matched",
1442
    taxon_best_match."*Genus_score",
1443
    taxon_best_match."*Specific_epithet_matched",
1444
    taxon_best_match."*Specific_epithet_score",
1445
    taxon_best_match."*Infraspecific_rank",
1446
    taxon_best_match."*Infraspecific_epithet_matched",
1447
    taxon_best_match."*Infraspecific_epithet_score",
1448
    taxon_best_match."*Infraspecific_rank_2",
1449
    taxon_best_match."*Infraspecific_epithet_2_matched",
1450
    taxon_best_match."*Infraspecific_epithet_2_score",
1451
    taxon_best_match."*Annotations",
1452
    taxon_best_match."*Unmatched_terms",
1453
    taxon_best_match."*Taxonomic_status",
1454
    taxon_best_match."*Accepted_name",
1455
    taxon_best_match."*Accepted_name_author",
1456
    taxon_best_match."*Accepted_name_rank",
1457
    taxon_best_match."*Accepted_name_url",
1458
    taxon_best_match."*Accepted_name_species",
1459
    taxon_best_match."*Accepted_name_family",
1460
    taxon_best_match."*Selected",
1461
    taxon_best_match."*Source",
1462
    taxon_best_match."*Warnings",
1463
    taxon_best_match."*Accepted_name_lsid",
1464
    taxon_best_match.is_valid_match,
1465
    taxon_best_match.scrubbed_unique_taxon_name,
1466
    taxon_best_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1467
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1468
    taxon_best_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1469
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1470
    taxon_best_match.matched_has_accepted,
1471
    taxon_best_match."Accepted_family__@TNRS__@vegpath.org",
1472
    taxon_best_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1473
    taxon_best_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1474
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1475
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1476
    taxon_best_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1477
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1478
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1479
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1480
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1481
    taxon_best_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1482
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1483
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1484
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1485
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1486
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1487
    taxon_best_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1488
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1489
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1490
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1491
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1492
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1493
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1494
        CASE
1495
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1496
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1497
            ELSE taxon_best_match."*Accepted_name_species"
1498
        END AS accepted_morphospecies_binomial
1499
   FROM taxon_best_match;
1500

    
1501

    
1502
--
1503
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1504
--
1505

    
1506
COMMENT ON VIEW "MatchedTaxon" IS '
1507
to modify:
1508
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1509
SELECT __
1510
$$);
1511
';
1512

    
1513

    
1514
--
1515
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1516
--
1517

    
1518
CREATE VIEW "ValidMatchedTaxon" AS
1519
 SELECT "MatchedTaxon".batch,
1520
    "MatchedTaxon".match_num,
1521
    "MatchedTaxon"."*Name_number",
1522
    "MatchedTaxon"."*Name_submitted",
1523
    "MatchedTaxon"."*Overall_score",
1524
    "MatchedTaxon"."*Name_matched",
1525
    "MatchedTaxon"."*Name_matched_rank",
1526
    "MatchedTaxon"."*Name_score",
1527
    "MatchedTaxon"."*Name_matched_author",
1528
    "MatchedTaxon"."*Name_matched_url",
1529
    "MatchedTaxon"."*Author_matched",
1530
    "MatchedTaxon"."*Author_score",
1531
    "MatchedTaxon"."*Family_matched",
1532
    "MatchedTaxon"."*Family_score",
1533
    "MatchedTaxon"."*Name_matched_accepted_family",
1534
    "MatchedTaxon"."*Genus_matched",
1535
    "MatchedTaxon"."*Genus_score",
1536
    "MatchedTaxon"."*Specific_epithet_matched",
1537
    "MatchedTaxon"."*Specific_epithet_score",
1538
    "MatchedTaxon"."*Infraspecific_rank",
1539
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1540
    "MatchedTaxon"."*Infraspecific_epithet_score",
1541
    "MatchedTaxon"."*Infraspecific_rank_2",
1542
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1543
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1544
    "MatchedTaxon"."*Annotations",
1545
    "MatchedTaxon"."*Unmatched_terms",
1546
    "MatchedTaxon"."*Taxonomic_status",
1547
    "MatchedTaxon"."*Accepted_name",
1548
    "MatchedTaxon"."*Accepted_name_author",
1549
    "MatchedTaxon"."*Accepted_name_rank",
1550
    "MatchedTaxon"."*Accepted_name_url",
1551
    "MatchedTaxon"."*Accepted_name_species",
1552
    "MatchedTaxon"."*Accepted_name_family",
1553
    "MatchedTaxon"."*Selected",
1554
    "MatchedTaxon"."*Source",
1555
    "MatchedTaxon"."*Warnings",
1556
    "MatchedTaxon"."*Accepted_name_lsid",
1557
    "MatchedTaxon".is_valid_match,
1558
    "MatchedTaxon".scrubbed_unique_taxon_name,
1559
    "MatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1560
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1561
    "MatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1562
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1563
    "MatchedTaxon".matched_has_accepted,
1564
    "MatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1565
    "MatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1566
    "MatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1567
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1568
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1569
    "MatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1570
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1571
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1572
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1573
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1574
    "MatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1575
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1576
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1577
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1578
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1579
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1580
    "MatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1581
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1582
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1583
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1584
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1585
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1586
    "MatchedTaxon"."taxonomicStatus",
1587
    "MatchedTaxon".accepted_morphospecies_binomial
1588
   FROM "MatchedTaxon"
1589
  WHERE "MatchedTaxon".is_valid_match;
1590

    
1591

    
1592
--
1593
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1594
--
1595

    
1596
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1597
to update, use * as the column list
1598
';
1599

    
1600

    
1601
--
1602
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1603
--
1604

    
1605
CREATE TABLE batch (
1606
    id text NOT NULL,
1607
    id_by_time text,
1608
    time_submitted timestamp with time zone DEFAULT now(),
1609
    client_version text
1610
);
1611

    
1612

    
1613
--
1614
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1615
--
1616

    
1617
CREATE TABLE batch_download_settings (
1618
    id text NOT NULL,
1619
    "E-mail" text,
1620
    "Id" text,
1621
    "Job type" text,
1622
    "Contains Id" boolean,
1623
    "Start time" text,
1624
    "Finish time" text,
1625
    "TNRS version" text,
1626
    "Sources selected" text,
1627
    "Match threshold" double precision,
1628
    "Classification" text,
1629
    "Allow partial matches?" boolean,
1630
    "Sort by source" boolean,
1631
    "Constrain by higher taxonomy" boolean
1632
);
1633

    
1634

    
1635
--
1636
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1637
--
1638

    
1639
COMMENT ON TABLE batch_download_settings IS '
1640
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1641
';
1642

    
1643

    
1644
--
1645
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1646
--
1647

    
1648
CREATE TABLE client_version (
1649
    id text NOT NULL,
1650
    global_rev integer NOT NULL,
1651
    "/lib/tnrs.py rev" integer,
1652
    "/bin/tnrs_db rev" integer
1653
);
1654

    
1655

    
1656
--
1657
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1658
--
1659

    
1660
COMMENT ON TABLE client_version IS '
1661
contains svn revisions
1662
';
1663

    
1664

    
1665
--
1666
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1667
--
1668

    
1669
COMMENT ON COLUMN client_version.global_rev IS '
1670
from `svn info .` > Last Changed Rev
1671
';
1672

    
1673

    
1674
--
1675
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1676
--
1677

    
1678
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1679
from `svn info lib/tnrs.py` > Last Changed Rev
1680
';
1681

    
1682

    
1683
--
1684
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1685
--
1686

    
1687
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1688
from `svn info bin/tnrs_db` > Last Changed Rev
1689
';
1690

    
1691

    
1692
--
1693
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1694
--
1695

    
1696
CREATE VIEW taxon_match_input AS
1697
 SELECT taxon_match."*Name_number" AS "Name_number",
1698
    taxon_match."*Name_submitted" AS "Name_submitted",
1699
    taxon_match."*Overall_score" AS "Overall_score",
1700
    taxon_match."*Name_matched" AS "Name_matched",
1701
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1702
    taxon_match."*Name_score" AS "Name_score",
1703
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1704
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1705
    taxon_match."*Author_matched" AS "Author_matched",
1706
    taxon_match."*Author_score" AS "Author_score",
1707
    taxon_match."*Family_matched" AS "Family_matched",
1708
    taxon_match."*Family_score" AS "Family_score",
1709
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1710
    taxon_match."*Genus_matched" AS "Genus_matched",
1711
    taxon_match."*Genus_score" AS "Genus_score",
1712
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1713
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1714
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1715
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1716
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1717
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1718
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1719
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1720
    taxon_match."*Annotations" AS "Annotations",
1721
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1722
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1723
    taxon_match."*Accepted_name" AS "Accepted_name",
1724
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1725
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1726
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1727
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1728
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1729
    taxon_match."*Selected" AS "Selected",
1730
    taxon_match."*Source" AS "Source",
1731
    taxon_match."*Warnings" AS "Warnings",
1732
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1733
   FROM taxon_match;
1734

    
1735

    
1736
--
1737
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1738
--
1739

    
1740
CREATE TABLE taxon_match_input__copy_to (
1741
    "Name_number" integer,
1742
    "Name_submitted" text,
1743
    "Overall_score" double precision,
1744
    "Name_matched" text,
1745
    "Name_matched_rank" text,
1746
    "Name_score" double precision,
1747
    "Name_matched_author" text,
1748
    "Name_matched_url" text,
1749
    "Author_matched" text,
1750
    "Author_score" double precision,
1751
    "Family_matched" text,
1752
    "Family_score" double precision,
1753
    "Name_matched_accepted_family" text,
1754
    "Genus_matched" text,
1755
    "Genus_score" double precision,
1756
    "Specific_epithet_matched" text,
1757
    "Specific_epithet_score" double precision,
1758
    "Infraspecific_rank" text,
1759
    "Infraspecific_epithet_matched" text,
1760
    "Infraspecific_epithet_score" double precision,
1761
    "Infraspecific_rank_2" text,
1762
    "Infraspecific_epithet_2_matched" text,
1763
    "Infraspecific_epithet_2_score" double precision,
1764
    "Annotations" text,
1765
    "Unmatched_terms" text,
1766
    "Taxonomic_status" text,
1767
    "Accepted_name" text,
1768
    "Accepted_name_author" text,
1769
    "Accepted_name_rank" text,
1770
    "Accepted_name_url" text,
1771
    "Accepted_name_species" text,
1772
    "Accepted_name_family" text,
1773
    "Selected" text,
1774
    "Source" text,
1775
    "Warnings" text,
1776
    "Accepted_name_lsid" text
1777
);
1778

    
1779

    
1780
--
1781
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1782
--
1783

    
1784
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1785
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1786
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1787
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1788
    taxon_match."*Genus_matched" AS scrubbed_genus,
1789
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1790
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1791
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1792
    taxon_match."*Name_matched_author" AS scrubbed_author,
1793
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1794
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1795
   FROM taxon_match;
1796

    
1797

    
1798
--
1799
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1800
--
1801

    
1802
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1803
to modify:
1804
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1805
SELECT __
1806
$$);
1807

    
1808
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.
1809
';
1810

    
1811

    
1812
--
1813
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1814
--
1815

    
1816
CREATE VIEW taxon_scrub AS
1817
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1818
    "ValidMatchedTaxon".batch,
1819
    "ValidMatchedTaxon".match_num,
1820
    "ValidMatchedTaxon"."*Name_number",
1821
    "ValidMatchedTaxon"."*Name_submitted",
1822
    "ValidMatchedTaxon"."*Overall_score",
1823
    "ValidMatchedTaxon"."*Name_matched",
1824
    "ValidMatchedTaxon"."*Name_matched_rank",
1825
    "ValidMatchedTaxon"."*Name_score",
1826
    "ValidMatchedTaxon"."*Name_matched_author",
1827
    "ValidMatchedTaxon"."*Name_matched_url",
1828
    "ValidMatchedTaxon"."*Author_matched",
1829
    "ValidMatchedTaxon"."*Author_score",
1830
    "ValidMatchedTaxon"."*Family_matched",
1831
    "ValidMatchedTaxon"."*Family_score",
1832
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1833
    "ValidMatchedTaxon"."*Genus_matched",
1834
    "ValidMatchedTaxon"."*Genus_score",
1835
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1836
    "ValidMatchedTaxon"."*Specific_epithet_score",
1837
    "ValidMatchedTaxon"."*Infraspecific_rank",
1838
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1839
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1840
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1841
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1842
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1843
    "ValidMatchedTaxon"."*Annotations",
1844
    "ValidMatchedTaxon"."*Unmatched_terms",
1845
    "ValidMatchedTaxon"."*Taxonomic_status",
1846
    "ValidMatchedTaxon"."*Accepted_name",
1847
    "ValidMatchedTaxon"."*Accepted_name_author",
1848
    "ValidMatchedTaxon"."*Accepted_name_rank",
1849
    "ValidMatchedTaxon"."*Accepted_name_url",
1850
    "ValidMatchedTaxon"."*Accepted_name_species",
1851
    "ValidMatchedTaxon"."*Accepted_name_family",
1852
    "ValidMatchedTaxon"."*Selected",
1853
    "ValidMatchedTaxon"."*Source",
1854
    "ValidMatchedTaxon"."*Warnings",
1855
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1856
    "ValidMatchedTaxon".is_valid_match,
1857
    "ValidMatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1858
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1859
    "ValidMatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1860
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1861
    "ValidMatchedTaxon".matched_has_accepted,
1862
    "ValidMatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1863
    "ValidMatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1864
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1865
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1866
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1867
    "ValidMatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1868
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1869
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1870
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1871
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1872
    "ValidMatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1873
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1874
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1875
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1876
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1877
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1878
    "ValidMatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1879
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1880
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1881
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1882
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1883
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1884
    "ValidMatchedTaxon"."taxonomicStatus",
1885
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1886
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1887
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1888
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1889
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1890
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1891
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1892
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1893
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1894
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1895
        CASE
1896
            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")
1897
            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")
1898
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1899
        END AS scrubbed_morphospecies_binomial
1900
   FROM ("ValidMatchedTaxon"
1901
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1902

    
1903

    
1904
--
1905
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1906
--
1907

    
1908
COMMENT ON VIEW taxon_scrub IS '
1909
to modify:
1910
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1911
SELECT __
1912
$$);
1913
';
1914

    
1915

    
1916
--
1917
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1918
--
1919

    
1920
ALTER TABLE ONLY batch_download_settings
1921
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1922

    
1923

    
1924
--
1925
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1926
--
1927

    
1928
ALTER TABLE ONLY batch
1929
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1930

    
1931

    
1932
--
1933
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1934
--
1935

    
1936
ALTER TABLE ONLY batch
1937
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1938

    
1939

    
1940
--
1941
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1942
--
1943

    
1944
ALTER TABLE ONLY client_version
1945
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1946

    
1947

    
1948
--
1949
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1950
--
1951

    
1952
ALTER TABLE ONLY taxon_match
1953
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1954

    
1955
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1956

    
1957

    
1958
--
1959
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1960
--
1961

    
1962
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1963

    
1964

    
1965
--
1966
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1967
--
1968

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

    
1971

    
1972
--
1973
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1974
--
1975

    
1976
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1977

    
1978

    
1979
--
1980
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1981
--
1982

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

    
1985

    
1986
--
1987
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1988
--
1989

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

    
1992

    
1993
--
1994
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1995
--
1996

    
1997
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
1998

    
1999

    
2000
--
2001
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2002
--
2003

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

    
2006

    
2007
--
2008
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
2009
--
2010

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

    
2013

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

    
2018
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
2019

    
2020

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

    
2025
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();
2026

    
2027

    
2028
--
2029
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2030
--
2031

    
2032
ALTER TABLE ONLY batch
2033
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
2034

    
2035

    
2036
--
2037
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2038
--
2039

    
2040
ALTER TABLE ONLY batch_download_settings
2041
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2042

    
2043

    
2044
--
2045
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2046
--
2047

    
2048
ALTER TABLE ONLY taxon_match
2049
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2050

    
2051

    
2052
--
2053
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
2054
--
2055

    
2056
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
2057
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
2058
GRANT ALL ON SCHEMA "TNRS" TO bien;
2059
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
2060

    
2061

    
2062
--
2063
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
2064
--
2065

    
2066
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
2067
REVOKE ALL ON TABLE taxon_match FROM bien;
2068
GRANT ALL ON TABLE taxon_match TO bien;
2069
GRANT SELECT ON TABLE taxon_match TO bien_read;
2070

    
2071

    
2072
--
2073
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
2074
--
2075

    
2076
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
2077
REVOKE ALL ON TABLE taxon_best_match FROM bien;
2078
GRANT ALL ON TABLE taxon_best_match TO bien;
2079
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
2080

    
2081

    
2082
--
2083
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2084
--
2085

    
2086
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
2087
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
2088
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
2089
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
2090

    
2091

    
2092
--
2093
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2094
--
2095

    
2096
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
2097
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
2098
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
2099
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
2100

    
2101

    
2102
--
2103
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
2104
--
2105

    
2106
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
2107
REVOKE ALL ON TABLE taxon_match_input FROM bien;
2108
GRANT ALL ON TABLE taxon_match_input TO bien;
2109
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
2110

    
2111

    
2112
--
2113
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
2114
--
2115

    
2116
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
2117
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
2118
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
2119
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
2120

    
2121

    
2122
--
2123
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
2124
--
2125

    
2126
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
2127
REVOKE ALL ON TABLE taxon_scrub FROM bien;
2128
GRANT ALL ON TABLE taxon_scrub TO bien;
2129
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
2130

    
2131

    
2132
--
2133
-- PostgreSQL database dump complete
2134
--
2135

    
(7-7/9)