Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/intersection tables #105

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"editor.formatOnSave": true
},
"cSpell.words": [
"bbox",
"BOOTSTRAPSERVERS",
"cdot",
"cimms",
Expand Down
68 changes: 67 additions & 1 deletion resources/sql_scripts/CVManager_CreateTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,70 @@ CREATE TABLE IF NOT EXISTS public.obu_ota_requests (
CONSTRAINT fk_manufacturer FOREIGN KEY (manufacturer) REFERENCES public.manufacturers(manufacturer_id)
);

CREATE SCHEMA IF NOT EXISTS keycloak;
CREATE SCHEMA IF NOT EXISTS keycloak;

-- Intersections
CREATE SEQUENCE public.intersections_intersection_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.intersections
(
intersection_id integer NOT NULL DEFAULT nextval('intersections_intersection_id_seq'::regclass),
intersection_number character varying(128) NOT NULL,
ref_pt GEOGRAPHY(POINT, 4326) NOT NULL,
bbox GEOGRAPHY(POLYGON, 4326),
intersection_name character varying(128),
origin_ip inet,
CONSTRAINT intersection_pkey PRIMARY KEY (intersection_id),
CONSTRAINT intersection_intersection_number UNIQUE (intersection_number)
);

CREATE SEQUENCE public.intersection_organization_intersection_organization_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.intersection_organization
(
intersection_organization_id integer NOT NULL DEFAULT nextval('intersection_organization_intersection_organization_id_seq'::regclass),
intersection_id integer NOT NULL,
organization_id integer NOT NULL,
CONSTRAINT intersection_organization_pkey PRIMARY KEY (intersection_organization_id),
CONSTRAINT fk_intersection_id FOREIGN KEY (intersection_id)
REFERENCES public.intersections (intersection_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT fk_organization_id FOREIGN KEY (organization_id)
REFERENCES public.organizations (organization_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);

CREATE SEQUENCE public.rsu_intersection_rsu_intersection_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.rsu_intersection
(
rsu_intersection_id integer NOT NULL DEFAULT nextval('rsu_intersection_rsu_intersection_id_seq'::regclass),
rsu_id integer NOT NULL,
intersection_id integer NOT NULL,
CONSTRAINT rsu_intersection_pkey PRIMARY KEY (rsu_intersection_id),
CONSTRAINT fk_rsu_id FOREIGN KEY (rsu_id)
REFERENCES public.rsus (rsu_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT fk_intersection_id FOREIGN KEY (intersection_id)
REFERENCES public.intersections (intersection_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
14 changes: 13 additions & 1 deletion resources/sql_scripts/CVManager_SampleData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@ INSERT INTO public.snmp_msgfwd_config(

INSERT INTO public.email_type(
email_type)
VALUES ('Support Requests'), ('Firmware Upgrade Failures'), ('Daily Message Counts');
VALUES ('Support Requests'), ('Firmware Upgrade Failures'), ('Daily Message Counts');

INSERT INTO public.intersections(
intersection_number, ref_pt, intersection_name)
VALUES (1, ST_GeomFromText('POINT(-105.014182 39.740422)'), 'Test Intersection');

INSERT INTO public.intersection_organization(
intersection_id, organization_id)
VALUES (1, 1);

INSERT INTO public.rsu_intersection(
rsu_id, intersection_id)
VALUES (1, 1);
65 changes: 65 additions & 0 deletions resources/sql_scripts/update_scripts/intersection_update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- Intersections
CREATE SEQUENCE public.intersections_intersection_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.intersections
(
intersection_id integer NOT NULL DEFAULT nextval('intersections_intersection_id_seq'::regclass),
intersection_number character varying(128) NOT NULL,
ref_pt GEOGRAPHY(POINT, 4326) NOT NULL,
bbox GEOGRAPHY(POLYGON, 4326),
intersection_name character varying(128),
origin_ip inet,
CONSTRAINT intersection_pkey PRIMARY KEY (intersection_id),
CONSTRAINT intersection_intersection_number UNIQUE (intersection_number)
);

CREATE SEQUENCE public.intersection_organization_intersection_organization_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.intersection_organization
(
intersection_organization_id integer NOT NULL DEFAULT nextval('intersection_organization_intersection_organization_id_seq'::regclass),
intersection_id integer NOT NULL,
organization_id integer NOT NULL,
CONSTRAINT intersection_organization_pkey PRIMARY KEY (intersection_organization_id),
CONSTRAINT fk_intersection_id FOREIGN KEY (intersection_id)
REFERENCES public.intersections (intersection_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT fk_organization_id FOREIGN KEY (organization_id)
REFERENCES public.organizations (organization_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);

CREATE SEQUENCE public.rsu_intersection_rsu_intersection_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;

CREATE TABLE IF NOT EXISTS public.rsu_intersection
(
rsu_intersection_id integer NOT NULL DEFAULT nextval('rsu_intersection_rsu_intersection_id_seq'::regclass),
rsu_id integer NOT NULL,
intersection_id integer NOT NULL,
CONSTRAINT rsu_intersection_pkey PRIMARY KEY (rsu_intersection_id),
CONSTRAINT fk_rsu_id FOREIGN KEY (rsu_id)
REFERENCES public.rsus (rsu_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT fk_intersection_id FOREIGN KEY (intersection_id)
REFERENCES public.intersections (intersection_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
Loading
Loading