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 'IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
24
on vegbiendev:
25
# back up existing TNRS schema (in case of an accidental incorrect change):
26
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
27
$ svn up
28
$ svn di
29
# make the changes shown in the diff
30
## to change column types:
31
SELECT util.set_col_types(''"TNRS".tnrs'', ARRAY[
32
  (''col'', ''new_type'')
33
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
34
$ 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

    
39

    
40
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
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
$$;
55

    
56

    
57
--
58
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
59
--
60

    
61
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

    
67

    
68
--
69
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
70
--
71

    
72
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

    
78

    
79
--
80
-- Name: tnrs_populate_fields(); Type: FUNCTION; Schema: TNRS; Owner: -
81
--
82

    
83
CREATE FUNCTION tnrs_populate_fields() RETURNS trigger
84
    LANGUAGE plpgsql
85
    AS $$
86
DECLARE
87
	"Specific_epithet_is_plant" boolean :=
88
		(CASE
89
		WHEN   new."Infraspecific_epithet_matched"	 IS NOT NULL
90
			OR new."Infraspecific_epithet_2_matched" IS NOT NULL
91
			OR new."Specific_epithet_score" >= 0.9 -- fuzzy match
92
			THEN true
93
		ELSE NULL -- ambiguous
94
		END);
95
	never_homonym boolean = COALESCE(new."Author_score" >= 0.6, false);
96
		-- author disambiguates
97
	family_is_homonym boolean = NOT never_homonym
98
		AND "TNRS".family_is_homonym(new."Family_matched");
99
	genus_is_homonym  boolean = NOT never_homonym
100
		AND "TNRS".genus_is_homonym(new."Genus_matched");
101
	matched_taxon_name_with_author text = NULLIF(concat_ws(' '
102
		, NULLIF(NULLIF(new."Name_matched_accepted_family", 'Unknown'),
103
			new."Name_matched")
104
		, NULLIF(new."Name_matched", 'No suitable matches found.')
105
		, new."Name_matched_author"
106
		), '');
107
	accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
108
		, NULLIF(NULLIF(new."Accepted_name_family", 'Unknown'),
109
			new."Accepted_name")
110
		, new."Accepted_name"
111
		, new."Accepted_name_author"
112
		), '');
113
BEGIN
114
	/* exclude homonyms because these are not valid matches (i.e. TNRS provides
115
	a name, but the name is not meaningful because it is not unambiguous). */
116
	new.is_valid_match = COALESCE(CASE
117
		WHEN new."Family_score" = 1 AND NOT family_is_homonym -- exact match
118
			THEN true
119
		ELSE -- consider genus
120
			(CASE
121
			WHEN new."Genus_score" =  1	   -- exact match
122
				THEN
123
				(CASE
124
				WHEN NOT genus_is_homonym THEN true
125
				ELSE "Specific_epithet_is_plant"
126
				END)
127
			WHEN new."Genus_score" >= 0.85 -- fuzzy match
128
				THEN "Specific_epithet_is_plant"
129
			ELSE NULL -- ambiguous
130
			END)
131
		END, false);
132
	new.scrubbed_unique_taxon_name = COALESCE(
133
		accepted_taxon_name_with_author, matched_taxon_name_with_author);
134
	
135
	RETURN new;
136
END;
137
$$;
138

    
139

    
140
--
141
-- Name: FUNCTION tnrs_populate_fields(); Type: COMMENT; Schema: TNRS; Owner: -
142
--
143

    
144
COMMENT ON FUNCTION tnrs_populate_fields() IS 'IMPORTANT: when changing this function, you must regenerate the derived cols:
145
UPDATE "TNRS".tnrs SET "Name_submitted" = "Name_submitted"
146
runtime: 40 min ("5363526 rows affected, 2329840 ms execution time")
147
VACUUM ANALYZE "TNRS".tnrs -- to remove previous rows
148
runtime: 1.5 min ("92633 ms")';
149

    
150

    
151
SET default_tablespace = '';
152

    
153
SET default_with_oids = false;
154

    
155
--
156
-- Name: tnrs; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
157
--
158

    
159
CREATE TABLE tnrs (
160
    batch text DEFAULT now() NOT NULL,
161
    "Name_number" integer NOT NULL,
162
    "Name_submitted" text NOT NULL,
163
    "Overall_score" double precision,
164
    "Name_matched" text,
165
    "Name_matched_rank" text,
166
    "Name_score" double precision,
167
    "Name_matched_author" text,
168
    "Name_matched_url" text,
169
    "Author_matched" text,
170
    "Author_score" double precision,
171
    "Family_matched" text,
172
    "Family_score" double precision,
173
    "Name_matched_accepted_family" text,
174
    "Genus_matched" text,
175
    "Genus_score" double precision,
176
    "Specific_epithet_matched" text,
177
    "Specific_epithet_score" double precision,
178
    "Infraspecific_rank" text,
179
    "Infraspecific_epithet_matched" text,
180
    "Infraspecific_epithet_score" double precision,
181
    "Infraspecific_rank_2" text,
182
    "Infraspecific_epithet_2_matched" text,
183
    "Infraspecific_epithet_2_score" double precision,
184
    "Annotations" text,
185
    "Unmatched_terms" text,
186
    "Taxonomic_status" text,
187
    "Accepted_name" text,
188
    "Accepted_name_author" text,
189
    "Accepted_name_rank" text,
190
    "Accepted_name_url" text,
191
    "Accepted_name_species" text,
192
    "Accepted_name_family" text,
193
    "Selected" text,
194
    "Source" text,
195
    "Warnings" text,
196
    "Accepted_name_lsid" text,
197
    is_valid_match boolean NOT NULL,
198
    scrubbed_unique_taxon_name text
199
);
200

    
201

    
202
--
203
-- Name: TABLE tnrs; Type: COMMENT; Schema: TNRS; Owner: -
204
--
205

    
206
COMMENT ON TABLE tnrs IS 'IMPORTANT: when changing this table''s schema, you may need to re-run TNRS:
207
$ inputs/.TNRS/data.sql.run refresh';
208

    
209

    
210
--
211
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
212
--
213

    
214
CREATE VIEW "MatchedTaxon" AS
215
 SELECT tnrs.batch AS "*Name_matched.batch", 
216
    tnrs."Name_submitted" AS "concatenatedScientificName", 
217
    tnrs."Name_matched" AS "matchedTaxonName", 
218
    tnrs."Name_matched_rank" AS "matchedTaxonRank", 
219
    tnrs."Name_score" AS "*Name_matched.Name_score", 
220
    tnrs."Name_matched_author" AS "matchedScientificNameAuthorship", 
221
    tnrs."Name_matched_url" AS "matchedScientificNameID", 
222
    tnrs."Author_score" AS "*Name_matched.Author_score", 
223
    tnrs."Family_score" AS "matchedFamilyConfidence_fraction", 
224
    COALESCE(tnrs."Name_matched_accepted_family", tnrs."Accepted_name_family") AS "matchedFamily", 
225
    tnrs."Genus_matched" AS "matchedGenus", 
226
    tnrs."Genus_score" AS "matchedGenusConfidence_fraction", 
227
    tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet", 
228
    tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction", 
229
    tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet", 
230
    tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score", 
231
    tnrs."Annotations" AS "identificationQualifier", 
232
    tnrs."Unmatched_terms" AS "morphospeciesSuffix", 
233
    tnrs."Taxonomic_status" AS "taxonomicStatus", 
234
    tnrs."Accepted_name" AS "acceptedTaxonName", 
235
    tnrs."Accepted_name_author" AS "acceptedScientificNameAuthorship", 
236
    tnrs."Accepted_name_rank" AS "acceptedTaxonRank", 
237
    tnrs."Accepted_name_url" AS "acceptedScientificNameID", 
238
    tnrs."Accepted_name_species" AS "*Name_matched.Accepted_name_species", 
239
    tnrs."Accepted_name_family" AS "acceptedFamily", 
240
    tnrs."Selected" AS "*Name_matched.Selected", 
241
    tnrs."Source" AS "*Name_matched.Source", 
242
    tnrs."Warnings" AS "*Name_matched.Warnings", 
243
    tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid", 
244
    tnrs.is_valid_match AS taxon_scrub__is_valid_match, 
245
    tnrs.scrubbed_unique_taxon_name
246
   FROM tnrs;
247

    
248

    
249
--
250
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
251
--
252

    
253
CREATE VIEW "ValidMatchedTaxon" AS
254
 SELECT "MatchedTaxon"."*Name_matched.batch", 
255
    "MatchedTaxon"."concatenatedScientificName", 
256
    "MatchedTaxon"."matchedTaxonName", 
257
    "MatchedTaxon"."matchedTaxonRank", 
258
    "MatchedTaxon"."*Name_matched.Name_score", 
259
    "MatchedTaxon"."matchedScientificNameAuthorship", 
260
    "MatchedTaxon"."matchedScientificNameID", 
261
    "MatchedTaxon"."*Name_matched.Author_score", 
262
    "MatchedTaxon"."matchedFamilyConfidence_fraction", 
263
    "MatchedTaxon"."matchedFamily", 
264
    "MatchedTaxon"."matchedGenus", 
265
    "MatchedTaxon"."matchedGenusConfidence_fraction", 
266
    "MatchedTaxon"."matchedSpecificEpithet", 
267
    "MatchedTaxon"."matchedSpeciesConfidence_fraction", 
268
    "MatchedTaxon"."matchedInfraspecificEpithet", 
269
    "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score", 
270
    "MatchedTaxon"."identificationQualifier", 
271
    "MatchedTaxon"."morphospeciesSuffix", 
272
    "MatchedTaxon"."taxonomicStatus", 
273
    "MatchedTaxon"."acceptedTaxonName", 
274
    "MatchedTaxon"."acceptedScientificNameAuthorship", 
275
    "MatchedTaxon"."acceptedTaxonRank", 
276
    "MatchedTaxon"."acceptedScientificNameID", 
277
    "MatchedTaxon"."*Name_matched.Accepted_name_species", 
278
    "MatchedTaxon"."acceptedFamily", 
279
    "MatchedTaxon"."*Name_matched.Selected", 
280
    "MatchedTaxon"."*Name_matched.Source", 
281
    "MatchedTaxon"."*Name_matched.Warnings", 
282
    "MatchedTaxon"."*Name_matched.Accepted_name_lsid", 
283
    "MatchedTaxon".taxon_scrub__is_valid_match, 
284
    "MatchedTaxon".scrubbed_unique_taxon_name
285
   FROM "MatchedTaxon"
286
  WHERE "MatchedTaxon".taxon_scrub__is_valid_match;
287

    
288

    
289
--
290
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
291
--
292

    
293
COMMENT ON VIEW "ValidMatchedTaxon" IS 'to update, use * as the column list';
294

    
295

    
296
--
297
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
298
--
299

    
300
CREATE TABLE batch (
301
    id text NOT NULL,
302
    id_by_time text,
303
    time_submitted timestamp with time zone DEFAULT now(),
304
    client_version text
305
);
306

    
307

    
308
--
309
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
310
--
311

    
312
CREATE TABLE batch_download_settings (
313
    id text NOT NULL,
314
    "E-mail" text,
315
    "Id" text,
316
    "Job type" text,
317
    "Contains Id" boolean,
318
    "Start time" text,
319
    "Finish time" text,
320
    "TNRS version" text,
321
    "Sources selected" text,
322
    "Match threshold" double precision,
323
    "Classification" text,
324
    "Allow partial matches?" boolean,
325
    "Sort by source" boolean,
326
    "Constrain by higher taxonomy" boolean
327
);
328

    
329

    
330
--
331
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
332
--
333

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

    
336

    
337
--
338
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
339
--
340

    
341
CREATE TABLE client_version (
342
    id text NOT NULL,
343
    global_rev integer NOT NULL,
344
    "/lib/tnrs.py rev" integer,
345
    "/bin/tnrs_db rev" integer
346
);
347

    
348

    
349
--
350
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
351
--
352

    
353
COMMENT ON TABLE client_version IS 'contains svn revisions';
354

    
355

    
356
--
357
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
358
--
359

    
360
COMMENT ON COLUMN client_version.global_rev IS 'from `svn info .` > Last Changed Rev';
361

    
362

    
363
--
364
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
365
--
366

    
367
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS 'from `svn info lib/tnrs.py` > Last Changed Rev';
368

    
369

    
370
--
371
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
372
--
373

    
374
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS 'from `svn info bin/tnrs_db` > Last Changed Rev';
375

    
376

    
377
--
378
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
379
--
380

    
381
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
382
 SELECT tnrs."Name_submitted" AS scrubbed_unique_taxon_name, 
383
    tnrs."Name_matched_rank" AS scrubbed_taxon_rank, 
384
    tnrs."Name_matched_accepted_family" AS scrubbed_family, 
385
    tnrs."Genus_matched" AS scrubbed_genus, 
386
    tnrs."Specific_epithet_matched" AS scrubbed_specific_epithet, 
387
    tnrs."Infraspecific_rank" AS scrubbed_infraspecific_rank, 
388
    tnrs."Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet, 
389
    tnrs."Name_matched_author" AS scrubbed_author, 
390
    tnrs."Name_matched" AS scrubbed_taxon_name_no_author
391
   FROM tnrs;
392

    
393

    
394
--
395
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
396
--
397

    
398
CREATE VIEW taxon_scrub AS
399
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name, 
400
    "ValidMatchedTaxon"."*Name_matched.batch", 
401
    "ValidMatchedTaxon"."concatenatedScientificName", 
402
    "ValidMatchedTaxon"."matchedTaxonName", 
403
    "ValidMatchedTaxon"."matchedTaxonRank", 
404
    "ValidMatchedTaxon"."*Name_matched.Name_score", 
405
    "ValidMatchedTaxon"."matchedScientificNameAuthorship", 
406
    "ValidMatchedTaxon"."matchedScientificNameID", 
407
    "ValidMatchedTaxon"."*Name_matched.Author_score", 
408
    "ValidMatchedTaxon"."matchedFamilyConfidence_fraction", 
409
    "ValidMatchedTaxon"."matchedFamily", 
410
    "ValidMatchedTaxon"."matchedGenus", 
411
    "ValidMatchedTaxon"."matchedGenusConfidence_fraction", 
412
    "ValidMatchedTaxon"."matchedSpecificEpithet", 
413
    "ValidMatchedTaxon"."matchedSpeciesConfidence_fraction", 
414
    "ValidMatchedTaxon"."matchedInfraspecificEpithet", 
415
    "ValidMatchedTaxon"."*Name_matched.Infraspecific_epithet_score", 
416
    "ValidMatchedTaxon"."identificationQualifier", 
417
    "ValidMatchedTaxon"."morphospeciesSuffix", 
418
    "ValidMatchedTaxon"."taxonomicStatus", 
419
    "ValidMatchedTaxon"."acceptedTaxonName", 
420
    "ValidMatchedTaxon"."acceptedScientificNameAuthorship", 
421
    "ValidMatchedTaxon"."acceptedTaxonRank", 
422
    "ValidMatchedTaxon"."acceptedScientificNameID", 
423
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_species", 
424
    "ValidMatchedTaxon"."acceptedFamily", 
425
    "ValidMatchedTaxon"."*Name_matched.Selected", 
426
    "ValidMatchedTaxon"."*Name_matched.Source", 
427
    "ValidMatchedTaxon"."*Name_matched.Warnings", 
428
    "ValidMatchedTaxon"."*Name_matched.Accepted_name_lsid", 
429
    "ValidMatchedTaxon".taxon_scrub__is_valid_match, 
430
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank, 
431
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, 
432
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus, 
433
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet, 
434
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank, 
435
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet, 
436
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author, 
437
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author
438
   FROM ("ValidMatchedTaxon"
439
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
440

    
441

    
442
--
443
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
444
--
445

    
446
COMMENT ON VIEW taxon_scrub IS 'to update, use * as the column list';
447

    
448

    
449
--
450
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
451
--
452

    
453
ALTER TABLE ONLY batch_download_settings
454
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
455

    
456

    
457
--
458
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
459
--
460

    
461
ALTER TABLE ONLY batch
462
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
463

    
464

    
465
--
466
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
467
--
468

    
469
ALTER TABLE ONLY batch
470
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
471

    
472

    
473
--
474
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
475
--
476

    
477
ALTER TABLE ONLY client_version
478
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
479

    
480

    
481
--
482
-- Name: tnrs_Name_submitted_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
483
--
484

    
485
ALTER TABLE ONLY tnrs
486
    ADD CONSTRAINT "tnrs_Name_submitted_key" UNIQUE ("Name_submitted");
487

    
488

    
489
--
490
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
491
--
492

    
493
ALTER TABLE ONLY tnrs
494
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY (batch, "Name_number");
495

    
496

    
497
--
498
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
499
--
500

    
501
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
502

    
503

    
504
--
505
-- Name: tnrs__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
506
--
507

    
508
CREATE UNIQUE INDEX tnrs__valid_match ON tnrs USING btree ("Name_submitted") WHERE is_valid_match;
509

    
510

    
511
--
512
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
513
--
514

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

    
517

    
518
--
519
-- Name: tnrs_populate_fields; Type: TRIGGER; Schema: TNRS; Owner: -
520
--
521

    
522
CREATE TRIGGER tnrs_populate_fields BEFORE INSERT OR UPDATE ON tnrs FOR EACH ROW EXECUTE PROCEDURE tnrs_populate_fields();
523

    
524

    
525
--
526
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
527
--
528

    
529
ALTER TABLE ONLY batch
530
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
531

    
532

    
533
--
534
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
535
--
536

    
537
ALTER TABLE ONLY batch_download_settings
538
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
539

    
540

    
541
--
542
-- Name: tnrs_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
543
--
544

    
545
ALTER TABLE ONLY tnrs
546
    ADD CONSTRAINT tnrs_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
547

    
548

    
549
--
550
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
551
--
552

    
553
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
554
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
555
GRANT ALL ON SCHEMA "TNRS" TO bien;
556
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
557

    
558

    
559
--
560
-- Name: tnrs; Type: ACL; Schema: TNRS; Owner: -
561
--
562

    
563
REVOKE ALL ON TABLE tnrs FROM PUBLIC;
564
REVOKE ALL ON TABLE tnrs FROM bien;
565
GRANT ALL ON TABLE tnrs TO bien;
566
GRANT SELECT ON TABLE tnrs TO bien_read;
567

    
568

    
569
--
570
-- PostgreSQL database dump complete
571
--
572

    
(8-8/10)