diff --git a/src/main/resources/db/migration/V17__ObservationTimeSeries.sql b/src/main/resources/db/migration/V17__ObservationTimeSeries.sql new file mode 100644 index 0000000000000000000000000000000000000000..c278854b4599ea411fecb62c26f17911e28f94b1 --- /dev/null +++ b/src/main/resources/db/migration/V17__ObservationTimeSeries.sql @@ -0,0 +1,26 @@ +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 diff --git a/src/main/resources/db/migration/V18__ObservationDataSchema_Eplevikler.sql b/src/main/resources/db/migration/V18__ObservationDataSchema_Eplevikler.sql new file mode 100644 index 0000000000000000000000000000000000000000..6c5761efffc469584ec30c653f472f02be9d3910 --- /dev/null +++ b/src/main/resources/db/migration/V18__ObservationDataSchema_Eplevikler.sql @@ -0,0 +1,48 @@ +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