Project

General

Profile

1 10778 aaronmk
--
2
-- PostgreSQL database dump
3
--
4 10737 aaronmk
5 10778 aaronmk
SET statement_timeout = 0;
6 11708 aaronmk
SET lock_timeout = 0;
7 10778 aaronmk
SET client_encoding = 'UTF8';
8
SET standard_conforming_strings = on;
9
SET check_function_bodies = false;
10
SET client_min_messages = warning;
11
12 10737 aaronmk
--
13 10778 aaronmk
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
14
--
15 10737 aaronmk
16 10778 aaronmk
--CREATE SCHEMA "TNRS";
17 10725 aaronmk
18
19 11614 aaronmk
--
20
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
21
--
22
23
COMMENT ON SCHEMA "TNRS" IS 'IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
24 11617 aaronmk
on vegbiendev:
25
# back up existing TNRS schema (in case of an accidental incorrect change):
26 11614 aaronmk
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
27 11616 aaronmk
$ svn up
28
$ svn di
29
# make the changes shown in the diff
30
## to change column types:
31 11614 aaronmk
SELECT util.set_col_types(''"TNRS".tnrs'', ARRAY[
32
  (''col'', ''new_type'')
33 11616 aaronmk
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
34 11617 aaronmk
$ rm=1 inputs/.TNRS/schema.sql.run
35
# repeat until `svn di` shows no diff
36
# back up new TNRS schema:
37
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")';
38 11614 aaronmk
39
40 10778 aaronmk
SET search_path = "TNRS", pg_catalog;
41
42
--
43
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
44
--
45
46
CREATE FUNCTION batch__fill() RETURNS trigger
47
    LANGUAGE plpgsql
48
    AS $$
49 10728 aaronmk
BEGIN
50
	new.id_by_time = new.time_submitted;
51
	new.id = COALESCE(new.id, new.id_by_time);
52
	RETURN new;
53
END;
54 10778 aaronmk
$$;
55 10728 aaronmk
56
57
--
58 10778 aaronmk
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
59
--
60 10728 aaronmk
61 10778 aaronmk
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
62
    LANGUAGE sql STABLE STRICT
63
    AS $_$
64
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
65
$_$;
66 10736 aaronmk
67 10778 aaronmk
68 10736 aaronmk
--
69 10778 aaronmk
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
70
--
71 10736 aaronmk
72 10778 aaronmk
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
73
    LANGUAGE sql STABLE STRICT
74
    AS $_$
75
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
76
$_$;
77 7844 aaronmk
78 9985 aaronmk
79 10778 aaronmk
--
80 11709 aaronmk
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
81
--
82
83
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, scrubbed_unique_taxon_name text) RETURNS text
84
    LANGUAGE sql IMMUTABLE
85
    AS $_$
86
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
87
$_$;
88
89
90
--
91 10778 aaronmk
-- Name: tnrs_populate_fields(); Type: FUNCTION; Schema: TNRS; Owner: -
92
--
93
94
CREATE FUNCTION tnrs_populate_fields() RETURNS trigger
95
    LANGUAGE plpgsql
96
    AS $$
97 9763 aaronmk
DECLARE
98 11628 aaronmk
	"Specific_epithet_is_plant" boolean :=
99
		(CASE
100
		WHEN   new."Infraspecific_epithet_matched"	 IS NOT NULL
101
			OR new."Infraspecific_epithet_2_matched" IS NOT NULL
102
			OR new."Specific_epithet_score" >= 0.9 -- fuzzy match
103
			THEN true
104
		ELSE NULL -- ambiguous
105
		END);
106
	never_homonym boolean = COALESCE(new."Author_score" >= 0.6, false);
107
		-- author disambiguates
108
	family_is_homonym boolean = NOT never_homonym
109
		AND "TNRS".family_is_homonym(new."Family_matched");
110
	genus_is_homonym  boolean = NOT never_homonym
111
		AND "TNRS".genus_is_homonym(new."Genus_matched");
112
	matched_taxon_name_with_author text = NULLIF(concat_ws(' '
113
		, NULLIF(NULLIF(new."Name_matched_accepted_family", 'Unknown'),
114
			new."Name_matched")
115
		, NULLIF(new."Name_matched", 'No suitable matches found.')
116
		, new."Name_matched_author"
117
		), '');
118 11643 aaronmk
	accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
119 11628 aaronmk
		, NULLIF(NULLIF(new."Accepted_name_family", 'Unknown'),
120
			new."Accepted_name")
121
		, new."Accepted_name"
122
		, new."Accepted_name_author"
123
		), '');
124 11643 aaronmk
BEGIN
125 11629 aaronmk
	/* exclude homonyms because these are not valid matches (i.e. TNRS provides
126
	a name, but the name is not meaningful because it is not unambiguous). */
127 11711 aaronmk
	new.is_valid_match = new."Taxonomic_status" != 'Invalid'
128
		AND COALESCE(CASE
129 11628 aaronmk
		WHEN new."Family_score" = 1 AND NOT family_is_homonym -- exact match
130
			THEN true
131
		ELSE -- consider genus
132
			(CASE
133
			WHEN new."Genus_score" =  1	   -- exact match
134
				THEN
135
				(CASE
136
				WHEN NOT genus_is_homonym THEN true
137
				ELSE "Specific_epithet_is_plant"
138
				END)
139
			WHEN new."Genus_score" >= 0.85 -- fuzzy match
140
				THEN "Specific_epithet_is_plant"
141
			ELSE NULL -- ambiguous
142
			END)
143 11629 aaronmk
		END, false);
144 11632 aaronmk
	new.scrubbed_unique_taxon_name = COALESCE(
145 11643 aaronmk
		accepted_taxon_name_with_author, matched_taxon_name_with_author);
146 11628 aaronmk
147
	RETURN new;
148 7134 aaronmk
END;
149 10778 aaronmk
$$;
150
151
152
--
153
-- Name: FUNCTION tnrs_populate_fields(); Type: COMMENT; Schema: TNRS; Owner: -
154
--
155
156 10754 aaronmk
COMMENT ON FUNCTION tnrs_populate_fields() IS 'IMPORTANT: when changing this function, you must regenerate the derived cols:
157
UPDATE "TNRS".tnrs SET "Name_submitted" = "Name_submitted"
158 11715 aaronmk
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
159 10754 aaronmk
VACUUM ANALYZE "TNRS".tnrs -- to remove previous rows
160 11615 aaronmk
runtime: 1.5 min ("92633 ms")';
161 7134 aaronmk
162 7251 aaronmk
163 10778 aaronmk
SET default_tablespace = '';
164
165
SET default_with_oids = false;
166
167 10728 aaronmk
--
168 10778 aaronmk
-- Name: tnrs; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
169
--
170 7251 aaronmk
171 10778 aaronmk
CREATE TABLE tnrs (
172
    batch text DEFAULT now() NOT NULL,
173
    "Name_number" integer NOT NULL,
174
    "Name_submitted" text NOT NULL,
175
    "Overall_score" double precision,
176
    "Name_matched" text,
177
    "Name_matched_rank" text,
178
    "Name_score" double precision,
179
    "Name_matched_author" text,
180
    "Name_matched_url" text,
181
    "Author_matched" text,
182
    "Author_score" double precision,
183
    "Family_matched" text,
184
    "Family_score" double precision,
185
    "Name_matched_accepted_family" text,
186
    "Genus_matched" text,
187
    "Genus_score" double precision,
188
    "Specific_epithet_matched" text,
189
    "Specific_epithet_score" double precision,
190
    "Infraspecific_rank" text,
191
    "Infraspecific_epithet_matched" text,
192
    "Infraspecific_epithet_score" double precision,
193
    "Infraspecific_rank_2" text,
194
    "Infraspecific_epithet_2_matched" text,
195
    "Infraspecific_epithet_2_score" double precision,
196
    "Annotations" text,
197
    "Unmatched_terms" text,
198
    "Taxonomic_status" text,
199
    "Accepted_name" text,
200
    "Accepted_name_author" text,
201
    "Accepted_name_rank" text,
202
    "Accepted_name_url" text,
203
    "Accepted_name_species" text,
204
    "Accepted_name_family" text,
205
    "Selected" text,
206
    "Source" text,
207
    "Warnings" text,
208
    "Accepted_name_lsid" text,
209 11628 aaronmk
    is_valid_match boolean NOT NULL,
210 11632 aaronmk
    scrubbed_unique_taxon_name text
211 10778 aaronmk
);
212 7823 aaronmk
213 9759 aaronmk
214 10778 aaronmk
--
215
-- Name: TABLE tnrs; Type: COMMENT; Schema: TNRS; Owner: -
216
--
217 7823 aaronmk
218 10787 aaronmk
COMMENT ON TABLE tnrs IS 'IMPORTANT: when changing this table''s schema, you may need to re-run TNRS:
219 11614 aaronmk
$ inputs/.TNRS/data.sql.run refresh';
220 10778 aaronmk
221
222
--
223
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
224
--
225
226
CREATE VIEW "MatchedTaxon" AS
227 11708 aaronmk
 SELECT tnrs.batch AS "*Name_matched.batch",
228
    tnrs."Name_submitted" AS "concatenatedScientificName",
229
    tnrs."Name_matched" AS "matchedTaxonName",
230
    tnrs."Name_matched_rank" AS "matchedTaxonRank",
231
    tnrs."Name_score" AS "*Name_matched.Name_score",
232
    tnrs."Name_matched_author" AS "matchedScientificNameAuthorship",
233
    tnrs."Name_matched_url" AS "matchedScientificNameID",
234
    tnrs."Author_score" AS "*Name_matched.Author_score",
235
    tnrs."Family_score" AS "matchedFamilyConfidence_fraction",
236
    COALESCE(tnrs."Name_matched_accepted_family", tnrs."Accepted_name_family") AS "matchedFamily",
237
    tnrs."Genus_matched" AS "matchedGenus",
238
    tnrs."Genus_score" AS "matchedGenusConfidence_fraction",
239
    tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet",
240
    tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction",
241
    tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet",
242
    tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score",
243
    tnrs."Annotations" AS "identificationQualifier",
244
    tnrs."Unmatched_terms" AS "morphospeciesSuffix",
245
    tnrs."Taxonomic_status" AS "taxonomicStatus",
246 13439 aaronmk
    tnrs."Accepted_name" AS scrubbed_taxon_name_no_author,
247
    tnrs."Accepted_name_author" AS scrubbed_author,
248
    tnrs."Accepted_name_rank" AS scrubbed_taxon_rank,
249 11708 aaronmk
    tnrs."Accepted_name_url" AS "acceptedScientificNameID",
250
    tnrs."Accepted_name_species" AS "*Name_matched.Accepted_name_species",
251 13439 aaronmk
    tnrs."Accepted_name_family" AS scrubbed_family,
252 11708 aaronmk
    tnrs."Selected" AS "*Name_matched.Selected",
253
    tnrs."Source" AS "*Name_matched.Source",
254
    tnrs."Warnings" AS "*Name_matched.Warnings",
255
    tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid",
256
    tnrs.is_valid_match AS taxon_scrub__is_valid_match,
257
    tnrs.scrubbed_unique_taxon_name
258
   FROM tnrs;
259 10778 aaronmk
260
261
--
262
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
263
--
264
265
CREATE VIEW "ValidMatchedTaxon" AS
266 11708 aaronmk
 SELECT "MatchedTaxon"."*Name_matched.batch",
267
    "MatchedTaxon"."concatenatedScientificName",
268
    "MatchedTaxon"."matchedTaxonName",
269
    "MatchedTaxon"."matchedTaxonRank",
270
    "MatchedTaxon"."*Name_matched.Name_score",
271
    "MatchedTaxon"."matchedScientificNameAuthorship",
272
    "MatchedTaxon"."matchedScientificNameID",
273
    "MatchedTaxon"."*Name_matched.Author_score",
274
    "MatchedTaxon"."matchedFamilyConfidence_fraction",
275
    "MatchedTaxon"."matchedFamily",
276
    "MatchedTaxon"."matchedGenus",
277
    "MatchedTaxon"."matchedGenusConfidence_fraction",
278
    "MatchedTaxon"."matchedSpecificEpithet",
279
    "MatchedTaxon"."matchedSpeciesConfidence_fraction",
280
    "MatchedTaxon"."matchedInfraspecificEpithet",
281
    "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score",
282
    "MatchedTaxon"."identificationQualifier",
283
    "MatchedTaxon"."morphospeciesSuffix",
284
    "MatchedTaxon"."taxonomicStatus",
285 13439 aaronmk
    "MatchedTaxon".scrubbed_taxon_name_no_author,
286
    "MatchedTaxon".scrubbed_author,
287
    "MatchedTaxon".scrubbed_taxon_rank,
288 11708 aaronmk
    "MatchedTaxon"."acceptedScientificNameID",
289
    "MatchedTaxon"."*Name_matched.Accepted_name_species",
290 13439 aaronmk
    "MatchedTaxon".scrubbed_family,
291 11708 aaronmk
    "MatchedTaxon"."*Name_matched.Selected",
292
    "MatchedTaxon"."*Name_matched.Source",
293
    "MatchedTaxon"."*Name_matched.Warnings",
294
    "MatchedTaxon"."*Name_matched.Accepted_name_lsid",
295
    "MatchedTaxon".taxon_scrub__is_valid_match,
296
    "MatchedTaxon".scrubbed_unique_taxon_name
297
   FROM "MatchedTaxon"
298
  WHERE "MatchedTaxon".taxon_scrub__is_valid_match;
299 10778 aaronmk
300
301
--
302
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
303
--
304
305
COMMENT ON VIEW "ValidMatchedTaxon" IS 'to update, use * as the column list';
306
307
308
--
309
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
310
--
311
312
CREATE TABLE batch (
313
    id text NOT NULL,
314
    id_by_time text,
315
    time_submitted timestamp with time zone DEFAULT now(),
316
    client_version text
317
);
318
319
320
--
321
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
322
--
323
324
CREATE TABLE batch_download_settings (
325
    id text NOT NULL,
326
    "E-mail" text,
327
    "Id" text,
328
    "Job type" text,
329
    "Contains Id" boolean,
330
    "Start time" text,
331
    "Finish time" text,
332
    "TNRS version" text,
333
    "Sources selected" text,
334
    "Match threshold" double precision,
335
    "Classification" text,
336
    "Allow partial matches?" boolean,
337
    "Sort by source" boolean,
338
    "Constrain by higher taxonomy" boolean
339
);
340
341
342
--
343
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
344
--
345
346
COMMENT ON TABLE batch_download_settings IS 'stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt';
347
348
349
--
350
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
351
--
352
353
CREATE TABLE client_version (
354
    id text NOT NULL,
355
    global_rev integer NOT NULL,
356
    "/lib/tnrs.py rev" integer,
357
    "/bin/tnrs_db rev" integer
358
);
359
360
361
--
362
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
363
--
364
365
COMMENT ON TABLE client_version IS 'contains svn revisions';
366
367
368
--
369
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
370
--
371
372
COMMENT ON COLUMN client_version.global_rev IS 'from `svn info .` > Last Changed Rev';
373
374
375
--
376
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
377
--
378
379
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS 'from `svn info lib/tnrs.py` > Last Changed Rev';
380
381
382
--
383
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
384
--
385
386
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS 'from `svn info bin/tnrs_db` > Last Changed Rev';
387
388
389
--
390 11964 aaronmk
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
391
--
392
393
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
394
 SELECT tnrs."Name_submitted" AS scrubbed_unique_taxon_name,
395 13439 aaronmk
    tnrs."Name_matched_rank" AS scrubbed_parsed_taxon_rank,
396
    COALESCE(tnrs."Name_matched_accepted_family", tnrs."Family_matched") AS scrubbed_parsed_family,
397 11964 aaronmk
    tnrs."Genus_matched" AS scrubbed_genus,
398
    tnrs."Specific_epithet_matched" AS scrubbed_specific_epithet,
399
    tnrs."Infraspecific_rank" AS scrubbed_infraspecific_rank,
400
    tnrs."Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
401 13439 aaronmk
    tnrs."Name_matched_author" AS scrubbed_parsed_author,
402
    tnrs."Name_matched" AS scrubbed_parsed_taxon_name_no_author
403 11964 aaronmk
   FROM tnrs;
404
405
406
--
407 11965 aaronmk
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
408
--
409
410
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '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.';
411
412
413
--
414 11964 aaronmk
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
415
--
416
417
CREATE VIEW taxon_scrub AS
418
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
419
    "ValidMatchedTaxon"."*Name_matched.batch",
420
    "ValidMatchedTaxon"."concatenatedScientificName",
421
    "ValidMatchedTaxon"."matchedTaxonName",
422
    "ValidMatchedTaxon"."matchedTaxonRank",
423
    "ValidMatchedTaxon"."*Name_matched.Name_score",
424
    "ValidMatchedTaxon"."matchedScientificNameAuthorship",
425
    "ValidMatchedTaxon"."matchedScientificNameID",
426
    "ValidMatchedTaxon"."*Name_matched.Author_score",
427
    "ValidMatchedTaxon"."matchedFamilyConfidence_fraction",
428
    "ValidMatchedTaxon"."matchedFamily",
429
    "ValidMatchedTaxon"."matchedGenus",
430
    "ValidMatchedTaxon"."matchedGenusConfidence_fraction",
431
    "ValidMatchedTaxon"."matchedSpecificEpithet",
432
    "ValidMatchedTaxon"."matchedSpeciesConfidence_fraction",
433
    "ValidMatchedTaxon"."matchedInfraspecificEpithet",
434
    "ValidMatchedTaxon"."*Name_matched.Infraspecific_epithet_score",
435
    "ValidMatchedTaxon"."identificationQualifier",
436
    "ValidMatchedTaxon"."morphospeciesSuffix",
437
    "ValidMatchedTaxon"."taxonomicStatus",
438 13439 aaronmk
    "ValidMatchedTaxon".scrubbed_taxon_name_no_author,
439
    "ValidMatchedTaxon".scrubbed_author,
440
    "ValidMatchedTaxon".scrubbed_taxon_rank,
441 11964 aaronmk
    "ValidMatchedTaxon"."acceptedScientificNameID",
442
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_species",
443 13439 aaronmk
    "ValidMatchedTaxon".scrubbed_family,
444 11964 aaronmk
    "ValidMatchedTaxon"."*Name_matched.Selected",
445
    "ValidMatchedTaxon"."*Name_matched.Source",
446
    "ValidMatchedTaxon"."*Name_matched.Warnings",
447
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_lsid",
448
    "ValidMatchedTaxon".taxon_scrub__is_valid_match,
449 13439 aaronmk
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_parsed_taxon_rank,
450
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_parsed_family,
451 11964 aaronmk
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
452
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
453
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
454
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
455 13439 aaronmk
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_parsed_author,
456
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_parsed_taxon_name_no_author
457 11964 aaronmk
   FROM ("ValidMatchedTaxon"
458
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
459
460
461
--
462
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
463
--
464
465
COMMENT ON VIEW taxon_scrub IS 'to update, use * as the column list';
466
467
468
--
469 10778 aaronmk
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
470
--
471
472
ALTER TABLE ONLY batch_download_settings
473
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
474
475
476
--
477
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
478
--
479
480
ALTER TABLE ONLY batch
481
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
482
483
484
--
485
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
486
--
487
488
ALTER TABLE ONLY batch
489
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
490
491
492
--
493
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
494
--
495
496
ALTER TABLE ONLY client_version
497
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
498
499
500
--
501
-- Name: tnrs_Name_submitted_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
502
--
503
504
ALTER TABLE ONLY tnrs
505
    ADD CONSTRAINT "tnrs_Name_submitted_key" UNIQUE ("Name_submitted");
506
507
508
--
509
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
510
--
511
512
ALTER TABLE ONLY tnrs
513
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY (batch, "Name_number");
514
515
516
--
517 10793 aaronmk
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
518
--
519
520
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
521
522
523
--
524 11607 aaronmk
-- Name: tnrs__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
525
--
526
527
CREATE UNIQUE INDEX tnrs__valid_match ON tnrs USING btree ("Name_submitted") WHERE is_valid_match;
528
529
530
--
531 10778 aaronmk
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
532
--
533
534
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
535
536
537
--
538
-- Name: tnrs_populate_fields; Type: TRIGGER; Schema: TNRS; Owner: -
539
--
540
541
CREATE TRIGGER tnrs_populate_fields BEFORE INSERT OR UPDATE ON tnrs FOR EACH ROW EXECUTE PROCEDURE tnrs_populate_fields();
542
543
544
--
545
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
546
--
547
548
ALTER TABLE ONLY batch
549
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
550
551
552
--
553
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
554
--
555
556
ALTER TABLE ONLY batch_download_settings
557
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
558
559
560
--
561
-- Name: tnrs_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
562
--
563
564
ALTER TABLE ONLY tnrs
565
    ADD CONSTRAINT tnrs_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
566
567
568
--
569
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
570
--
571
572
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
573
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
574
GRANT ALL ON SCHEMA "TNRS" TO bien;
575
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
576
577
578
--
579
-- Name: tnrs; Type: ACL; Schema: TNRS; Owner: -
580
--
581
582
REVOKE ALL ON TABLE tnrs FROM PUBLIC;
583
REVOKE ALL ON TABLE tnrs FROM bien;
584
GRANT ALL ON TABLE tnrs TO bien;
585
GRANT SELECT ON TABLE tnrs TO bien_read;
586
587
588
--
589 11912 aaronmk
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
590
--
591
592
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
593
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
594
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
595
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
596
597
598
--
599
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
600
--
601
602
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
603
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
604
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
605
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
606
607
608
--
609
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
610
--
611
612
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
613
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
614
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
615
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
616
617
618
--
619
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
620
--
621
622
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
623
REVOKE ALL ON TABLE taxon_scrub FROM bien;
624
GRANT ALL ON TABLE taxon_scrub TO bien;
625
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
626
627
628
--
629 10778 aaronmk
-- PostgreSQL database dump complete
630
--