Revision 6885
Added by Aaron Marcuse-Kubitza over 11 years ago
vegbien.sql | ||
---|---|---|
1011 | 1011 |
|
1012 | 1012 |
|
1013 | 1013 |
-- |
1014 |
-- Name: sync_taxon_trait_to_view(); Type: FUNCTION; Schema: public; Owner: - |
|
1015 |
-- |
|
1016 |
|
|
1017 |
CREATE FUNCTION sync_taxon_trait_to_view() RETURNS void |
|
1018 |
LANGUAGE sql |
|
1019 |
AS $$ |
|
1020 |
DROP TABLE IF EXISTS taxon_trait; |
|
1021 |
CREATE TABLE taxon_trait AS SELECT * FROM taxon_trait_view LIMIT 0; |
|
1022 |
|
|
1023 |
GRANT SELECT ON TABLE taxon_trait TO bien_read; |
|
1024 |
GRANT SELECT ON TABLE taxon_trait_view TO bien_read; |
|
1025 |
|
|
1026 |
ALTER TABLE taxon_trait ADD PRIMARY KEY ("scientificName", "measurementType"); |
|
1027 |
$$; |
|
1028 |
|
|
1029 |
|
|
1030 |
-- |
|
1014 | 1031 |
-- Name: taxondetermination_set_iscurrent(); Type: FUNCTION; Schema: public; Owner: - |
1015 | 1032 |
-- |
1016 | 1033 |
|
... | ... | |
4081 | 4098 |
|
4082 | 4099 |
|
4083 | 4100 |
-- |
4101 |
-- Name: taxon_trait; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
4102 |
-- |
|
4103 |
|
|
4104 |
CREATE TABLE taxon_trait ( |
|
4105 |
"scientificName" text NOT NULL, |
|
4106 |
"measurementType" text NOT NULL, |
|
4107 |
"measurementValue" text, |
|
4108 |
"measurementUnit" text |
|
4109 |
); |
|
4110 |
|
|
4111 |
|
|
4112 |
-- |
|
4113 |
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
4114 |
-- |
|
4115 |
|
|
4116 |
CREATE TABLE trait ( |
|
4117 |
trait_id integer NOT NULL, |
|
4118 |
taxonoccurrence_id integer NOT NULL, |
|
4119 |
name text NOT NULL, |
|
4120 |
value text, |
|
4121 |
units text |
|
4122 |
); |
|
4123 |
|
|
4124 |
|
|
4125 |
-- |
|
4126 |
-- Name: taxon_trait_view; Type: VIEW; Schema: public; Owner: - |
|
4127 |
-- |
|
4128 |
|
|
4129 |
CREATE VIEW taxon_trait_view AS |
|
4130 |
SELECT accepted_taxonlabel.taxonomicname AS "scientificName", trait.name AS "measurementType", trait.value AS "measurementValue", trait.name AS "measurementUnit" FROM (((((trait LEFT JOIN taxonoccurrence USING (taxonoccurrence_id)) LEFT JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) LEFT JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) WHERE COALESCE(taxondetermination.iscurrent, true); |
|
4131 |
|
|
4132 |
|
|
4133 |
-- |
|
4084 | 4134 |
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: |
4085 | 4135 |
-- |
4086 | 4136 |
|
... | ... | |
4466 | 4516 |
|
4467 | 4517 |
|
4468 | 4518 |
-- |
4469 |
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
4470 |
-- |
|
4471 |
|
|
4472 |
CREATE TABLE trait ( |
|
4473 |
trait_id integer NOT NULL, |
|
4474 |
taxonoccurrence_id integer NOT NULL, |
|
4475 |
name text NOT NULL, |
|
4476 |
value text, |
|
4477 |
units text |
|
4478 |
); |
|
4479 |
|
|
4480 |
|
|
4481 |
-- |
|
4482 | 4519 |
-- Name: trait_trait_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
4483 | 4520 |
-- |
4484 | 4521 |
|
... | ... | |
5382 | 5419 |
|
5383 | 5420 |
|
5384 | 5421 |
-- |
5422 |
-- Data for Name: taxon_trait; Type: TABLE DATA; Schema: public; Owner: - |
|
5423 |
-- |
|
5424 |
|
|
5425 |
|
|
5426 |
|
|
5427 |
-- |
|
5385 | 5428 |
-- Data for Name: taxonalt; Type: TABLE DATA; Schema: public; Owner: - |
5386 | 5429 |
-- |
5387 | 5430 |
|
... | ... | |
5944 | 5987 |
|
5945 | 5988 |
|
5946 | 5989 |
-- |
5990 |
-- Name: taxon_trait_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
5991 |
-- |
|
5992 |
|
|
5993 |
ALTER TABLE ONLY taxon_trait |
|
5994 |
ADD CONSTRAINT taxon_trait_pkey PRIMARY KEY ("scientificName", "measurementType"); |
|
5995 |
|
|
5996 |
|
|
5997 |
-- |
|
5947 | 5998 |
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
5948 | 5999 |
-- |
5949 | 6000 |
|
... | ... | |
8407 | 8458 |
|
8408 | 8459 |
|
8409 | 8460 |
-- |
8461 |
-- Name: taxon_trait; Type: ACL; Schema: public; Owner: - |
|
8462 |
-- |
|
8463 |
|
|
8464 |
REVOKE ALL ON TABLE taxon_trait FROM PUBLIC; |
|
8465 |
REVOKE ALL ON TABLE taxon_trait FROM bien; |
|
8466 |
GRANT ALL ON TABLE taxon_trait TO bien; |
|
8467 |
GRANT SELECT ON TABLE taxon_trait TO bien_read; |
|
8468 |
|
|
8469 |
|
|
8470 |
-- |
|
8471 |
-- Name: trait; Type: ACL; Schema: public; Owner: - |
|
8472 |
-- |
|
8473 |
|
|
8474 |
REVOKE ALL ON TABLE trait FROM PUBLIC; |
|
8475 |
REVOKE ALL ON TABLE trait FROM bien; |
|
8476 |
GRANT ALL ON TABLE trait TO bien; |
|
8477 |
GRANT SELECT ON TABLE trait TO bien_read; |
|
8478 |
|
|
8479 |
|
|
8480 |
-- |
|
8481 |
-- Name: taxon_trait_view; Type: ACL; Schema: public; Owner: - |
|
8482 |
-- |
|
8483 |
|
|
8484 |
REVOKE ALL ON TABLE taxon_trait_view FROM PUBLIC; |
|
8485 |
REVOKE ALL ON TABLE taxon_trait_view FROM bien; |
|
8486 |
GRANT ALL ON TABLE taxon_trait_view TO bien; |
|
8487 |
GRANT SELECT ON TABLE taxon_trait_view TO bien_read; |
|
8488 |
|
|
8489 |
|
|
8490 |
-- |
|
8410 | 8491 |
-- Name: taxonalt; Type: ACL; Schema: public; Owner: - |
8411 | 8492 |
-- |
8412 | 8493 |
|
... | ... | |
8497 | 8578 |
|
8498 | 8579 |
|
8499 | 8580 |
-- |
8500 |
-- Name: trait; Type: ACL; Schema: public; Owner: - |
|
8501 |
-- |
|
8502 |
|
|
8503 |
REVOKE ALL ON TABLE trait FROM PUBLIC; |
|
8504 |
REVOKE ALL ON TABLE trait FROM bien; |
|
8505 |
GRANT ALL ON TABLE trait TO bien; |
|
8506 |
GRANT SELECT ON TABLE trait TO bien_read; |
|
8507 |
|
|
8508 |
|
|
8509 |
-- |
|
8510 | 8581 |
-- Name: userdefined; Type: ACL; Schema: public; Owner: - |
8511 | 8582 |
-- |
8512 | 8583 |
|
Also available in: Unified diff
schemas/vegbien.sql: Added taxon_trait materialized view