Skip to content
Snippets Groups Projects
Commit 6fad8b85 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Add db migrations for timeseries and eplevikler

parent bf313b37
No related branches found
No related tags found
1 merge request!173ObservationDataSchema for eplevikler and ObservationTimeSeries
CREATE TABLE IF NOT EXISTS public.observation_time_series
(
observation_time_series_id SERIAL PRIMARY KEY,
crop_organism_id integer NOT NULL,
organism_id integer NOT NULL,
year integer NOT NULL,
name character varying(1023) NOT NULL,
description text,
source character varying(6) NOT NULL DEFAULT 'WEB',
user_id integer NOT NULL,
created timestamp with time zone NOT NULL,
last_modified_by integer,
last_modified timestamp with time zone,
location_point_of_interest_id integer NOT NULL,
location_is_private boolean DEFAULT false,
polygon_service_id integer,
CONSTRAINT observation_time_series_crop_organism_id_fkey FOREIGN KEY (crop_organism_id) REFERENCES public.organism (organism_id),
CONSTRAINT observation_time_series_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES public.organism (organism_id),
CONSTRAINT observation_time_series_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.vips_logic_user (user_id),
CONSTRAINT observation_time_series_last_modified_by_fkey FOREIGN KEY (last_modified_by) REFERENCES public.vips_logic_user (user_id),
CONSTRAINT observation_time_series_location_point_of_interest_id_fkey FOREIGN KEY (location_point_of_interest_id) REFERENCES public.point_of_interest (point_of_interest_id),
CONSTRAINT observation_time_series_polygon_service_id_fkey FOREIGN KEY (polygon_service_id) REFERENCES public.polygon_service (polygon_service_id)
);
ALTER TABLE observation ADD COLUMN source character varying(6) NOT NULL DEFAULT 'WEB';
ALTER TABLE observation ADD COLUMN observation_time_series_id integer REFERENCES public.observation_time_series(observation_time_series_id);
\ No newline at end of file
INSERT INTO public.observation_data_schema
(organization_id, organism_id, data_schema, data_model)
VALUES (1, 68,
'{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": " ",
"properties": {
"trap1": {
"title": "Antall insekter, felle 1",
"type": "number",
"minimum": 0,
"default": 0
},
"trap2": {
"title": "Antall insekter, felle 2",
"type": "number",
"minimum": 0,
"default": 0
},
"trap3": {
"title": "Antall insekter, felle 3",
"type": "number",
"minimum": 0,
"default": 0
},
"trap4": {
"title": "Antall insekter, felle 4",
"type": "number",
"minimum": 0,
"default": 0
},
"bbch": {
"title": "BBCH",
"type": "number",
"minimum": 0,
"default": 0
}
}
}',
'{
"trap1":0,
"trap2":0,
"trap3":0,
"trap4":0,
"bbch":0
}'
);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment