Skip to content

Commit

Permalink
STU-25778: Add aggregation and processing_type tables
Browse files Browse the repository at this point in the history
  • Loading branch information
mpartio committed Nov 28, 2024
1 parent 2512df3 commit 42a2ad6
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ for f in producer_class producer_class-data \
producer_meta producer_meta-data \
projection projection-data \
forecast_type forecast_type-data \
aggregation aggregation-data \
processing_type processing_type-data \
earth_shape earth_shape-data \
datum datum-data \
geom geom-data \
Expand Down
11 changes: 11 additions & 0 deletions doc/aggregation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Aggregation contains information about any aggregations done to the parameter over some time period.

For example maximum of a temperature, or accumulation of precipitation.

| column | data type | NOT NULL | description | foreign key |
|---|---|---|---|---|
| id | integer (serial) | X | auto-generated primary key | |
| name | varchar(50) | | aggregation name | |
| description | text | | description of the aggregation | |
| last_updater | text | | username of the last modifier | |
| last_updated | timestamptz | | time of last modification | |
11 changes: 11 additions & 0 deletions doc/processing_type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Processing_type contains information about any statistical processing done to the parameter.

For example a probability or a fractile.

| column | data type | NOT NULL | description | foreign key |
|---|---|---|---|---|
| id | integer (serial) | X | auto-generated primary key | |
| name | varchar(50) | | processing type name | |
| description | text | | description of the processing type | |
| last_updater | text | | username of the last modifier | |
| last_updated | timestamptz | | time of last modification | |
38 changes: 38 additions & 0 deletions sql/aggregation-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

--
-- Data for Name: aggregation; Type: TABLE DATA; Schema: public; Owner: wetodb
--

COPY aggregation (id, name, description, last_updater, last_updated) FROM stdin;
1 INSTANT No aggregation \N \N
2 MEAN Mean over time period \N \N
3 ACCUMULATION Accumulation over time period \N \N
4 MAX Maximum over time period \N \N
5 MIN Minimum over time period \N \N
6 RANGE Range (maximum minus minimum) over time period \N \N
7 MEDIAN Median value over time period \N \N
8 VAR Variance over time period \N \N
9 STDE Standard deviation over time period \N \N
10 MODE Most common value over time period \N \N
11 INTENSITY Peak intensity over time period \N \N
12 DOMINANCE Dominant or prevailing value over time period \N \N
\.

SELECT pg_catalog.setval('aggregation_id_seq', 12, true);

--
-- PostgreSQL database dump complete
--

119 changes: 119 additions & 0 deletions sql/aggregation.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: aggregation; Type: TABLE; Schema: public; Owner: wetodb; Tablespace:
--

CREATE TABLE aggregation (
id integer NOT NULL,
name character varying(50) NOT NULL,
description text NOT NULL,
last_updater text,
last_updated timestamp(0) without time zone
);


ALTER TABLE public.aggregation OWNER TO radon_admin;

--
-- Name: COLUMN aggregation.last_updater; Type: COMMENT; Schema: public; Owner: wetodb
--

COMMENT ON COLUMN aggregation.last_updater IS 'Fixed column for last updater';


--
-- Name: COLUMN aggregation.last_updated; Type: COMMENT; Schema: public; Owner: wetodb
--

COMMENT ON COLUMN aggregation.last_updated IS 'Fixed column for last updating time';


--
-- Name: aggregation_id_seq; Type: SEQUENCE; Schema: public; Owner: wetodb
--

CREATE SEQUENCE aggregation_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.aggregation_id_seq OWNER TO radon_admin;

--
-- Name: aggregation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: wetodb
--

ALTER SEQUENCE aggregation_id_seq OWNED BY aggregation.id;


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: wetodb
--

ALTER TABLE ONLY aggregation ALTER COLUMN id SET DEFAULT nextval('aggregation_id_seq'::regclass);


--
-- Name: aggregation_name_version_idx; Type: CONSTRAINT; Schema: public; Owner: wetodb; Tablespace:
--

ALTER TABLE ONLY aggregation
ADD CONSTRAINT aggregation_name_idx UNIQUE (name);


--
-- Name: aggregation_pkey; Type: CONSTRAINT; Schema: public; Owner: wetodb; Tablespace:
--

ALTER TABLE ONLY aggregation
ADD CONSTRAINT aggregation_pkey PRIMARY KEY (id);


--
-- Name: audit_trigger_row; Type: TRIGGER; Schema: public; Owner: wetodb
--

CREATE TRIGGER audit_trigger_row AFTER UPDATE ON aggregation FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func('true');


--
-- Name: aggregation_store_last_updated_trg; Type: TRIGGER; Schema: public; Owner: wetodb
--

CREATE TRIGGER aggregation_store_last_updated_trg BEFORE UPDATE ON aggregation FOR EACH ROW EXECUTE PROCEDURE store_last_updated_f();


--
-- Name: aggregation; Type: ACL; Schema: public; Owner: wetodb
--

REVOKE ALL ON TABLE aggregation FROM PUBLIC;
REVOKE ALL ON TABLE aggregation FROM wetodb;
GRANT ALL ON TABLE aggregation TO wetodb;
GRANT SELECT ON TABLE aggregation TO radon_ro;
GRANT INSERT,DELETE,UPDATE ON TABLE aggregation TO radon_rw;


--
-- PostgreSQL database dump complete
--

50 changes: 50 additions & 0 deletions sql/processing_type-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

--
-- Data for Name: processing_type; Type: TABLE DATA; Schema: public; Owner: wetodb
--

COPY processing_type (id, name, description, last_updater, last_updated) FROM stdin;
1 UNPROCESSED No processing \N \N
2 PROBGE Probability greater than or equal \N \N
3 PROBGT Probability greater than \N \N
4 PROBLE Probability less than or equal \N \N
5 PROBLT Probability less than \N \N
6 PROBEQ Probability equal to \N \N
7 PROBIN Probability equal to list of values \N \N
8 FRACTILE Fractile \N \N
9 PROBGE_AREA Probability greater than or equal, using an area aggregation \N \N
10 PROBGT_AREA Probability greater than, using an area aggregation \N \N
11 PROBLE_AREA Probability less than or equal, using an area aggregation \N \N
12 PROBLT_AREA Probability less than, using an area aggregation \N \N
13 PROBEQ_AREA Probability equal to, using an area aggregation \N \N
14 PROBIN_AREA Probability in list of values, using an area aggregation \N \N
15 BIAS_CORR Bias correction \N \N
16 MEAN Mean value \N \N
17 STDE Standard deviation \N \N
18 FILTERED Smoothing or filtering \N \N
19 DETREND Trends (long-term climate effects) removed \N \N
20 ANOMALY Anomaly \N \N
21 NORMALIZED Normalized to specific range or relative to mean/stde \N \N
22 CLIMATOLOGY Climate normal or climatology \N \N
23 CATEGORIZED Categorization of continuous variables \N \N
24 PERCENT_CHANGE Percentage change relative to baseline \N \N
\.

SELECT pg_catalog.setval('processing_type_id_seq', 24, true);

--
-- PostgreSQL database dump complete
--

119 changes: 119 additions & 0 deletions sql/processing_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: processing_type; Type: TABLE; Schema: public; Owner: wetodb; Tablespace:
--

CREATE TABLE processing_type (
id integer NOT NULL,
name character varying(50) NOT NULL,
description text NOT NULL,
last_updater text,
last_updated timestamp(0) without time zone
);


ALTER TABLE public.processing_type OWNER TO radon_admin;

--
-- Name: COLUMN processing_type.last_updater; Type: COMMENT; Schema: public; Owner: wetodb
--

COMMENT ON COLUMN processing_type.last_updater IS 'Fixed column for last updater';


--
-- Name: COLUMN processing_type.last_updated; Type: COMMENT; Schema: public; Owner: wetodb
--

COMMENT ON COLUMN processing_type.last_updated IS 'Fixed column for last updating time';


--
-- Name: processing_type_id_seq; Type: SEQUENCE; Schema: public; Owner: wetodb
--

CREATE SEQUENCE processing_type_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.processing_type_id_seq OWNER TO radon_admin;

--
-- Name: processing_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: wetodb
--

ALTER SEQUENCE processing_type_id_seq OWNED BY processing_type.id;


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: wetodb
--

ALTER TABLE ONLY processing_type ALTER COLUMN id SET DEFAULT nextval('processing_type_id_seq'::regclass);


--
-- Name: processing_type_name_version_idx; Type: CONSTRAINT; Schema: public; Owner: wetodb; Tablespace:
--

ALTER TABLE ONLY processing_type
ADD CONSTRAINT processing_type_name_idx UNIQUE (name);


--
-- Name: processing_type_pkey; Type: CONSTRAINT; Schema: public; Owner: wetodb; Tablespace:
--

ALTER TABLE ONLY processing_type
ADD CONSTRAINT processing_type_pkey PRIMARY KEY (id);


--
-- Name: audit_trigger_row; Type: TRIGGER; Schema: public; Owner: wetodb
--

CREATE TRIGGER audit_trigger_row AFTER UPDATE ON processing_type FOR EACH ROW EXECUTE PROCEDURE audit.if_modified_func('true');


--
-- Name: processing_type_store_last_updated_trg; Type: TRIGGER; Schema: public; Owner: wetodb
--

CREATE TRIGGER processing_type_store_last_updated_trg BEFORE UPDATE ON processing_type FOR EACH ROW EXECUTE PROCEDURE store_last_updated_f();


--
-- Name: processing_type; Type: ACL; Schema: public; Owner: wetodb
--

REVOKE ALL ON TABLE processing_type FROM PUBLIC;
REVOKE ALL ON TABLE processing_type FROM wetodb;
GRANT ALL ON TABLE processing_type TO wetodb;
GRANT SELECT ON TABLE processing_type TO radon_ro;
GRANT INSERT,DELETE,UPDATE ON TABLE processing_type TO radon_rw;


--
-- PostgreSQL database dump complete
--

0 comments on commit 42a2ad6

Please sign in to comment.