Project

General

Profile

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

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

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

    
15
--CREATE SCHEMA "TNRS";
16

    
17

    
18
SET search_path = "TNRS", pg_catalog;
19

    
20
--
21
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
22
--
23

    
24
CREATE FUNCTION batch__fill() RETURNS trigger
25
    LANGUAGE plpgsql
26
    AS $$
27
BEGIN
28
	new.id_by_time = new.time_submitted;
29
	new.id = COALESCE(new.id, new.id_by_time);
30
	RETURN new;
31
END;
32
$$;
33

    
34

    
35
--
36
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
37
--
38

    
39
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
40
    LANGUAGE sql STABLE STRICT
41
    AS $_$
42
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
43
$_$;
44

    
45

    
46
--
47
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
48
--
49

    
50
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
51
    LANGUAGE sql STABLE STRICT
52
    AS $_$
53
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
54
$_$;
55

    
56

    
57
--
58
-- Name: score_ok(double precision); Type: FUNCTION; Schema: TNRS; Owner: -
59
--
60

    
61
CREATE FUNCTION score_ok(score double precision) RETURNS boolean
62
    LANGUAGE sql IMMUTABLE STRICT
63
    AS $_$
64
SELECT $1 >= 0.8
65
$_$;
66

    
67

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

    
72
CREATE FUNCTION tnrs_populate_fields() RETURNS trigger
73
    LANGUAGE plpgsql
74
    AS $$
75
DECLARE
76
    "Specific_epithet_is_plant" boolean :=
77
        (CASE
78
        WHEN   new."Infraspecific_epithet_matched"   IS NOT NULL
79
            OR new."Infraspecific_epithet_2_matched" IS NOT NULL
80
            OR new."Specific_epithet_score" >= 0.9 -- fuzzy match
81
            THEN true
82
        ELSE NULL -- ambiguous
83
        END);
84
    never_homonym boolean = COALESCE(new."Author_score" >= 0.6, false); -- author disambiguates
85
    family_is_homonym boolean = NOT never_homonym AND "TNRS".family_is_homonym(new."Family_matched");
86
    genus_is_homonym  boolean = NOT never_homonym AND "TNRS".genus_is_homonym( new."Genus_matched" );
87
BEGIN
88
    new."Accepted_scientific_name" = NULLIF(concat_ws(' '
89
        , NULLIF(NULLIF(new."Accepted_name_family", 'Unknown'), new."Accepted_name")
90
        , new."Accepted_name"
91
        , new."Accepted_name_author"
92
    ), '');
93
    new."Max_score" = GREATEST(
94
          new."Overall_score"
95
        , new."Family_score"
96
        , new."Genus_score"
97
        , new."Specific_epithet_score"
98
    );
99
    new."Is_homonym" = COALESCE(genus_is_homonym, family_is_homonym);
100
    new."Is_plant" = (CASE
101
        WHEN new."Family_score" = 1 AND NOT family_is_homonym -- exact match
102
            THEN true
103
        ELSE -- consider genus
104
            (CASE
105
            WHEN new."Genus_score" =  1    -- exact match
106
                THEN
107
                (CASE
108
                WHEN NOT genus_is_homonym THEN true
109
                ELSE "Specific_epithet_is_plant"
110
                END)
111
            WHEN new."Genus_score" >= 0.85 -- fuzzy match
112
                THEN "Specific_epithet_is_plant"
113
            ELSE NULL -- ambiguous
114
            END)
115
        END);
116
    /* exclude homonyms because these are not valid matches (i.e. TNRS provides
117
    a name, but the name is not meaningful because it is not unambiguous) */
118
    new.is_valid_match = COALESCE("TNRS".score_ok(new."Max_score"), false)
119
        AND COALESCE(new."Is_plant", false);
120
    
121
    RETURN new;
122
END;
123
$$;
124

    
125

    
126
--
127
-- Name: FUNCTION tnrs_populate_fields(); Type: COMMENT; Schema: TNRS; Owner: -
128
--
129

    
130
COMMENT ON FUNCTION tnrs_populate_fields() IS 'IMPORTANT: when changing this function, you must regenerate the derived cols:
131
UPDATE "TNRS".tnrs SET "Name_submitted" = "Name_submitted"
132
runtime: 25 min ("5221748 rows affected, 1524228 ms execution time")
133
VACUUM ANALYZE "TNRS".tnrs -- to remove previous rows
134
runtime: 1 min ("62350 ms")';
135

    
136

    
137
SET default_tablespace = '';
138

    
139
SET default_with_oids = false;
140

    
141
--
142
-- Name: tnrs; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
143
--
144

    
145
CREATE TABLE tnrs (
146
    batch text DEFAULT now() NOT NULL,
147
    "Name_number" integer NOT NULL,
148
    "Name_submitted" text NOT NULL,
149
    "Overall_score" double precision,
150
    "Name_matched" text,
151
    "Name_matched_rank" text,
152
    "Name_score" double precision,
153
    "Name_matched_author" text,
154
    "Name_matched_url" text,
155
    "Author_matched" text,
156
    "Author_score" double precision,
157
    "Family_matched" text,
158
    "Family_score" double precision,
159
    "Name_matched_accepted_family" text,
160
    "Genus_matched" text,
161
    "Genus_score" double precision,
162
    "Specific_epithet_matched" text,
163
    "Specific_epithet_score" double precision,
164
    "Infraspecific_rank" text,
165
    "Infraspecific_epithet_matched" text,
166
    "Infraspecific_epithet_score" double precision,
167
    "Infraspecific_rank_2" text,
168
    "Infraspecific_epithet_2_matched" text,
169
    "Infraspecific_epithet_2_score" double precision,
170
    "Annotations" text,
171
    "Unmatched_terms" text,
172
    "Taxonomic_status" text,
173
    "Accepted_name" text,
174
    "Accepted_name_author" text,
175
    "Accepted_name_rank" text,
176
    "Accepted_name_url" text,
177
    "Accepted_name_species" text,
178
    "Accepted_name_family" text,
179
    "Selected" text,
180
    "Source" text,
181
    "Warnings" text,
182
    "Accepted_name_lsid" text,
183
    "Accepted_scientific_name" text,
184
    "Max_score" double precision,
185
    "Is_homonym" boolean,
186
    "Is_plant" boolean,
187
    is_valid_match boolean NOT NULL
188
);
189

    
190

    
191
--
192
-- Name: TABLE tnrs; Type: COMMENT; Schema: TNRS; Owner: -
193
--
194

    
195
COMMENT ON TABLE tnrs IS 'IMPORTANT: when changing this table''s schema, you may need to re-run TNRS:
196
$ inputs/.TNRS/data.sql.run refresh
197
you must also make the same changes on vegbiendev: e.g.
198
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
199
SELECT util.set_col_types(''"TNRS".tnrs'', ARRAY[
200
  (''col'', ''new_type'')
201
]::util.col_cast[]);
202
runtime: 9 min ("531282 ms")';
203

    
204

    
205
--
206
-- Name: AcceptedTaxon; Type: VIEW; Schema: TNRS; Owner: -
207
--
208

    
209
CREATE VIEW "AcceptedTaxon" AS
210
    SELECT tnrs.batch AS "*Accepted_name.batch", tnrs."Name_submitted" AS "acceptedScientificName", tnrs."Genus_matched" AS "acceptedGenus", tnrs."Specific_epithet_matched" AS "acceptedSpecificEpithet", tnrs."Infraspecific_epithet_matched" AS "acceptedInfraspecificEpithet", tnrs."Taxonomic_status" AS "acceptedTaxonomicStatus", tnrs."Selected" AS "*Accepted_name.Selected", tnrs."Source" AS "*Accepted_name.Source", tnrs."Warnings" AS "*Accepted_name.Warnings", tnrs."Accepted_name_lsid" AS "*Accepted_name.Accepted_name_lsid" FROM tnrs;
211

    
212

    
213
--
214
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
215
--
216

    
217
CREATE VIEW "MatchedTaxon" AS
218
    SELECT tnrs.batch AS "*Name_matched.batch", tnrs."Name_submitted" AS "concatenatedScientificName", tnrs."Name_matched" AS "matchedTaxonName", tnrs."Name_matched_rank" AS "matchedTaxonRank", tnrs."Name_score" AS "*Name_matched.Name_score", tnrs."Name_matched_author" AS "matchedScientificNameAuthorship", tnrs."Name_matched_url" AS "matchedScientificNameID", tnrs."Author_score" AS "*Name_matched.Author_score", tnrs."Family_score" AS "matchedFamilyConfidence_fraction", COALESCE(tnrs."Name_matched_accepted_family", tnrs."Accepted_name_family") AS "matchedFamily", tnrs."Genus_matched" AS "matchedGenus", tnrs."Genus_score" AS "matchedGenusConfidence_fraction", tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet", tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction", tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet", tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score", tnrs."Annotations" AS "identificationQualifier", tnrs."Unmatched_terms" AS "morphospeciesSuffix", tnrs."Taxonomic_status" AS "taxonomicStatus", tnrs."Accepted_name" AS "acceptedTaxonName", tnrs."Accepted_name_author" AS "acceptedScientificNameAuthorship", tnrs."Accepted_name_rank" AS "acceptedTaxonRank", tnrs."Accepted_name_url" AS "acceptedScientificNameID", tnrs."Accepted_name_species" AS "*Name_matched.Accepted_name_species", tnrs."Accepted_name_family" AS "acceptedFamily", tnrs."Selected" AS "*Name_matched.Selected", tnrs."Source" AS "*Name_matched.Source", tnrs."Warnings" AS "*Name_matched.Warnings", tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid", tnrs."Accepted_scientific_name" AS "acceptedScientificName", tnrs."Max_score" AS "matchedTaxonConfidence_fraction", tnrs.is_valid_match AS taxon_scrub__is_valid_match FROM tnrs;
219

    
220

    
221
--
222
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
223
--
224

    
225
CREATE VIEW "ValidMatchedTaxon" AS
226
    SELECT "MatchedTaxon"."*Name_matched.batch", "MatchedTaxon"."concatenatedScientificName", "MatchedTaxon"."matchedTaxonName", "MatchedTaxon"."matchedTaxonRank", "MatchedTaxon"."*Name_matched.Name_score", "MatchedTaxon"."matchedScientificNameAuthorship", "MatchedTaxon"."matchedScientificNameID", "MatchedTaxon"."*Name_matched.Author_score", "MatchedTaxon"."matchedFamilyConfidence_fraction", "MatchedTaxon"."matchedFamily", "MatchedTaxon"."matchedGenus", "MatchedTaxon"."matchedGenusConfidence_fraction", "MatchedTaxon"."matchedSpecificEpithet", "MatchedTaxon"."matchedSpeciesConfidence_fraction", "MatchedTaxon"."matchedInfraspecificEpithet", "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score", "MatchedTaxon"."identificationQualifier", "MatchedTaxon"."morphospeciesSuffix", "MatchedTaxon"."taxonomicStatus", "MatchedTaxon"."acceptedTaxonName", "MatchedTaxon"."acceptedScientificNameAuthorship", "MatchedTaxon"."acceptedTaxonRank", "MatchedTaxon"."acceptedScientificNameID", "MatchedTaxon"."*Name_matched.Accepted_name_species", "MatchedTaxon"."acceptedFamily", "MatchedTaxon"."*Name_matched.Selected", "MatchedTaxon"."*Name_matched.Source", "MatchedTaxon"."*Name_matched.Warnings", "MatchedTaxon"."*Name_matched.Accepted_name_lsid", "MatchedTaxon"."acceptedScientificName", "MatchedTaxon"."matchedTaxonConfidence_fraction", "MatchedTaxon".taxon_scrub__is_valid_match FROM "MatchedTaxon" WHERE "MatchedTaxon".taxon_scrub__is_valid_match;
227

    
228

    
229
--
230
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
231
--
232

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

    
235

    
236
--
237
-- Name: ScrubbedTaxon; Type: VIEW; Schema: TNRS; Owner: -
238
--
239

    
240
CREATE VIEW "ScrubbedTaxon" AS
241
    SELECT "ValidMatchedTaxon"."acceptedScientificName", "ValidMatchedTaxon"."*Name_matched.batch", "ValidMatchedTaxon"."concatenatedScientificName", "ValidMatchedTaxon"."matchedTaxonName", "ValidMatchedTaxon"."matchedTaxonRank", "ValidMatchedTaxon"."*Name_matched.Name_score", "ValidMatchedTaxon"."matchedScientificNameAuthorship", "ValidMatchedTaxon"."matchedScientificNameID", "ValidMatchedTaxon"."*Name_matched.Author_score", "ValidMatchedTaxon"."matchedFamilyConfidence_fraction", "ValidMatchedTaxon"."matchedFamily", "ValidMatchedTaxon"."matchedGenus", "ValidMatchedTaxon"."matchedGenusConfidence_fraction", "ValidMatchedTaxon"."matchedSpecificEpithet", "ValidMatchedTaxon"."matchedSpeciesConfidence_fraction", "ValidMatchedTaxon"."matchedInfraspecificEpithet", "ValidMatchedTaxon"."*Name_matched.Infraspecific_epithet_score", "ValidMatchedTaxon"."identificationQualifier", "ValidMatchedTaxon"."morphospeciesSuffix", "ValidMatchedTaxon"."taxonomicStatus", "ValidMatchedTaxon"."acceptedTaxonName", "ValidMatchedTaxon"."acceptedScientificNameAuthorship", "ValidMatchedTaxon"."acceptedTaxonRank", "ValidMatchedTaxon"."acceptedScientificNameID", "ValidMatchedTaxon"."*Name_matched.Accepted_name_species", "ValidMatchedTaxon"."acceptedFamily", "ValidMatchedTaxon"."*Name_matched.Selected", "ValidMatchedTaxon"."*Name_matched.Source", "ValidMatchedTaxon"."*Name_matched.Warnings", "ValidMatchedTaxon"."*Name_matched.Accepted_name_lsid", "ValidMatchedTaxon"."matchedTaxonConfidence_fraction", "AcceptedTaxon"."*Accepted_name.batch", "AcceptedTaxon"."acceptedGenus", "AcceptedTaxon"."acceptedSpecificEpithet", "AcceptedTaxon"."acceptedInfraspecificEpithet", "AcceptedTaxon"."acceptedTaxonomicStatus", "AcceptedTaxon"."*Accepted_name.Selected", "AcceptedTaxon"."*Accepted_name.Source", "AcceptedTaxon"."*Accepted_name.Warnings", "AcceptedTaxon"."*Accepted_name.Accepted_name_lsid" FROM ("ValidMatchedTaxon" NATURAL LEFT JOIN "AcceptedTaxon");
242

    
243

    
244
--
245
-- Name: VIEW "ScrubbedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
246
--
247

    
248
COMMENT ON VIEW "ScrubbedTaxon" IS 'to update, use * as the column list';
249

    
250

    
251
--
252
-- Name: Source; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
253
--
254

    
255
CREATE TABLE "Source" (
256
    "*row_num" integer NOT NULL,
257
    "sourceType" text DEFAULT 'aggregator'::text NOT NULL,
258
    "datasetURL" text DEFAULT 'http://tnrs.iplantcollaborative.org/TNRSapp.html'::text NOT NULL
259
);
260

    
261

    
262
--
263
-- Name: COLUMN "Source"."sourceType"; Type: COMMENT; Schema: TNRS; Owner: -
264
--
265

    
266
COMMENT ON COLUMN "Source"."sourceType" IS 'constant';
267

    
268

    
269
--
270
-- Name: COLUMN "Source"."datasetURL"; Type: COMMENT; Schema: TNRS; Owner: -
271
--
272

    
273
COMMENT ON COLUMN "Source"."datasetURL" IS 'constant';
274

    
275

    
276
--
277
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
278
--
279

    
280
CREATE TABLE batch (
281
    id text NOT NULL,
282
    id_by_time text,
283
    time_submitted timestamp with time zone DEFAULT now(),
284
    client_version text
285
);
286

    
287

    
288
--
289
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
290
--
291

    
292
CREATE TABLE batch_download_settings (
293
    id text NOT NULL,
294
    "E-mail" text,
295
    "Id" text,
296
    "Job type" text,
297
    "Contains Id" boolean,
298
    "Start time" text,
299
    "Finish time" text,
300
    "TNRS version" text,
301
    "Sources selected" text,
302
    "Match threshold" double precision,
303
    "Classification" text,
304
    "Allow partial matches?" boolean,
305
    "Sort by source" boolean,
306
    "Constrain by higher taxonomy" boolean
307
);
308

    
309

    
310
--
311
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
312
--
313

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

    
316

    
317
--
318
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
319
--
320

    
321
CREATE TABLE client_version (
322
    id text NOT NULL,
323
    global_rev integer NOT NULL,
324
    "/lib/tnrs.py rev" integer,
325
    "/bin/tnrs_db rev" integer
326
);
327

    
328

    
329
--
330
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
331
--
332

    
333
COMMENT ON TABLE client_version IS 'contains svn revisions';
334

    
335

    
336
--
337
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
338
--
339

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

    
342

    
343
--
344
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
345
--
346

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

    
349

    
350
--
351
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
352
--
353

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

    
356

    
357
--
358
-- Name: ~Source.map; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
359
--
360

    
361
CREATE TABLE "~Source.map" (
362
    "from" text NOT NULL,
363
    "to" text,
364
    filter text,
365
    notes text
366
);
367

    
368

    
369
--
370
-- Name: Source_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
371
--
372

    
373
ALTER TABLE ONLY "Source"
374
    ADD CONSTRAINT "Source_pkey" PRIMARY KEY ("*row_num");
375

    
376

    
377
--
378
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
379
--
380

    
381
ALTER TABLE ONLY batch_download_settings
382
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
383

    
384

    
385
--
386
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
387
--
388

    
389
ALTER TABLE ONLY batch
390
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
391

    
392

    
393
--
394
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
395
--
396

    
397
ALTER TABLE ONLY batch
398
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
399

    
400

    
401
--
402
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
403
--
404

    
405
ALTER TABLE ONLY client_version
406
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
407

    
408

    
409
--
410
-- Name: tnrs_Name_submitted_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
411
--
412

    
413
ALTER TABLE ONLY tnrs
414
    ADD CONSTRAINT "tnrs_Name_submitted_key" UNIQUE ("Name_submitted");
415

    
416

    
417
--
418
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
419
--
420

    
421
ALTER TABLE ONLY tnrs
422
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY (batch, "Name_number");
423

    
424

    
425
--
426
-- Name: ~Source.map_from_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
427
--
428

    
429
ALTER TABLE ONLY "~Source.map"
430
    ADD CONSTRAINT "~Source.map_from_key" UNIQUE ("from");
431

    
432

    
433
--
434
-- Name: ~Source.map_to_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
435
--
436

    
437
ALTER TABLE ONLY "~Source.map"
438
    ADD CONSTRAINT "~Source.map_to_key" UNIQUE ("to");
439

    
440

    
441
--
442
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
443
--
444

    
445
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
446

    
447

    
448
--
449
-- Name: tnrs__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
450
--
451

    
452
CREATE UNIQUE INDEX tnrs__valid_match ON tnrs USING btree ("Name_submitted") WHERE is_valid_match;
453

    
454

    
455
--
456
-- Name: tnrs_score_ok; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
457
--
458

    
459
CREATE UNIQUE INDEX tnrs_score_ok ON tnrs USING btree ("Name_submitted") WHERE score_ok("Max_score");
460

    
461

    
462
--
463
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
464
--
465

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

    
468

    
469
--
470
-- Name: map_filter_insert; Type: TRIGGER; Schema: TNRS; Owner: -
471
--
472

    
473
CREATE TRIGGER map_filter_insert BEFORE INSERT ON "~Source.map" FOR EACH ROW EXECUTE PROCEDURE util.map_filter_insert();
474

    
475
ALTER TABLE "~Source.map" DISABLE TRIGGER map_filter_insert;
476

    
477

    
478
--
479
-- Name: tnrs_populate_fields; Type: TRIGGER; Schema: TNRS; Owner: -
480
--
481

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

    
484

    
485
--
486
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
487
--
488

    
489
ALTER TABLE ONLY batch
490
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
491

    
492

    
493
--
494
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
495
--
496

    
497
ALTER TABLE ONLY batch_download_settings
498
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
499

    
500

    
501
--
502
-- Name: tnrs_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
503
--
504

    
505
ALTER TABLE ONLY tnrs
506
    ADD CONSTRAINT tnrs_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
507

    
508

    
509
--
510
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
511
--
512

    
513
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
514
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
515
GRANT ALL ON SCHEMA "TNRS" TO bien;
516
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
517

    
518

    
519
--
520
-- Name: tnrs; Type: ACL; Schema: TNRS; Owner: -
521
--
522

    
523
REVOKE ALL ON TABLE tnrs FROM PUBLIC;
524
REVOKE ALL ON TABLE tnrs FROM bien;
525
GRANT ALL ON TABLE tnrs TO bien;
526
GRANT SELECT ON TABLE tnrs TO bien_read;
527

    
528

    
529
--
530
-- PostgreSQL database dump complete
531
--
532

    
(8-8/10)