telemetry-model-v2.sql 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. -- Dumped from database version 11.12
  5. -- Dumped by pg_dump version 15.2
  6. -- Started on 2023-05-05 01:10:04
  7. SET statement_timeout = 0;
  8. SET lock_timeout = 0;
  9. SET idle_in_transaction_session_timeout = 0;
  10. SET client_encoding = 'UTF8';
  11. SET standard_conforming_strings = on;
  12. SELECT pg_catalog.set_config('search_path', '', false);
  13. SET check_function_bodies = false;
  14. SET xmloption = content;
  15. SET client_min_messages = warning;
  16. SET row_security = off;
  17. CREATE ROLE senslog NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT;
  18. CREATE ROLE maplog_app NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN PASSWORD 'MAPlog';
  19. GRANT senslog TO maplog_app;
  20. --
  21. -- TOC entry 3861 (class 1262 OID 54507)
  22. -- Name: maplog; Type: DATABASE; Schema: -; Owner: postgres
  23. --
  24. CREATE DATABASE maplog WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8';
  25. ALTER DATABASE maplog OWNER TO senslog;
  26. \connect maplog
  27. SET statement_timeout = 0;
  28. SET lock_timeout = 0;
  29. SET idle_in_transaction_session_timeout = 0;
  30. SET client_encoding = 'UTF8';
  31. SET standard_conforming_strings = on;
  32. SELECT pg_catalog.set_config('search_path', '', false);
  33. SET check_function_bodies = false;
  34. SET xmloption = content;
  35. SET client_min_messages = warning;
  36. SET row_security = off;
  37. --
  38. -- TOC entry 9 (class 2615 OID 55528)
  39. -- Name: maplog; Type: SCHEMA; Schema: -; Owner: postgres
  40. --
  41. CREATE SCHEMA maplog;
  42. ALTER SCHEMA maplog OWNER TO senslog;
  43. --
  44. -- TOC entry 7 (class 2615 OID 2200)
  45. -- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
  46. --
  47. -- *not* creating schema, since initdb creates it
  48. ALTER SCHEMA public OWNER TO senslog;
  49. --
  50. -- TOC entry 2 (class 3079 OID 54508)
  51. -- Name: postgis; Type: EXTENSION; Schema: -; Owner: -
  52. --
  53. CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
  54. --
  55. -- TOC entry 3863 (class 0 OID 0)
  56. -- Dependencies: 2
  57. -- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner:
  58. --
  59. COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions';
  60. SET default_tablespace = '';
  61. --
  62. -- TOC entry 216 (class 1259 OID 62701)
  63. -- Name: campaign; Type: TABLE; Schema: maplog; Owner: postgres
  64. --
  65. CREATE TABLE maplog.campaign (
  66. campaign_id integer NOT NULL,
  67. description text NOT NULL,
  68. from_time timestamp with time zone NOT NULL,
  69. to_time timestamp with time zone NOT NULL
  70. );
  71. ALTER TABLE maplog.campaign OWNER TO senslog;
  72. --
  73. -- TOC entry 215 (class 1259 OID 62699)
  74. -- Name: campaign_campaign_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  75. --
  76. CREATE SEQUENCE maplog.campaign_campaign_id_seq
  77. AS integer
  78. START WITH 1
  79. INCREMENT BY 1
  80. NO MINVALUE
  81. NO MAXVALUE
  82. CACHE 1;
  83. ALTER TABLE maplog.campaign_campaign_id_seq OWNER TO senslog;
  84. --
  85. -- TOC entry 3864 (class 0 OID 0)
  86. -- Dependencies: 215
  87. -- Name: campaign_campaign_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  88. --
  89. ALTER SEQUENCE maplog.campaign_campaign_id_seq OWNED BY maplog.campaign.campaign_id;
  90. --
  91. -- TOC entry 224 (class 1259 OID 62784)
  92. -- Name: groups; Type: TABLE; Schema: maplog; Owner: postgres
  93. --
  94. CREATE TABLE maplog.groups (
  95. group_id integer NOT NULL,
  96. group_name text,
  97. parent_group_id integer,
  98. has_children boolean DEFAULT false
  99. );
  100. ALTER TABLE maplog.groups OWNER TO senslog;
  101. --
  102. -- TOC entry 223 (class 1259 OID 62782)
  103. -- Name: group_group_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  104. --
  105. CREATE SEQUENCE maplog.group_group_id_seq
  106. AS integer
  107. START WITH 1
  108. INCREMENT BY 1
  109. NO MINVALUE
  110. NO MAXVALUE
  111. CACHE 1;
  112. ALTER TABLE maplog.group_group_id_seq OWNER TO senslog;
  113. --
  114. -- TOC entry 3865 (class 0 OID 0)
  115. -- Dependencies: 223
  116. -- Name: group_group_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  117. --
  118. ALTER SEQUENCE maplog.group_group_id_seq OWNED BY maplog.groups.group_id;
  119. --
  120. -- TOC entry 212 (class 1259 OID 55614)
  121. -- Name: obs_telemetry; Type: TABLE; Schema: maplog; Owner: postgres
  122. --
  123. CREATE TABLE maplog.obs_telemetry (
  124. obs_id bigint NOT NULL,
  125. time_stamp timestamp with time zone NOT NULL,
  126. unit_id bigint NOT NULL,
  127. observed_values jsonb NOT NULL,
  128. the_geom public.geometry(Point,4326),
  129. time_received timestamp with time zone DEFAULT now() NOT NULL
  130. );
  131. ALTER TABLE maplog.obs_telemetry OWNER TO senslog;
  132. --
  133. -- TOC entry 211 (class 1259 OID 55612)
  134. -- Name: obs_telemetry_obs_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  135. --
  136. CREATE SEQUENCE maplog.obs_telemetry_obs_id_seq
  137. START WITH 1
  138. INCREMENT BY 1
  139. NO MINVALUE
  140. NO MAXVALUE
  141. CACHE 1;
  142. ALTER TABLE maplog.obs_telemetry_obs_id_seq OWNER TO senslog;
  143. --
  144. -- TOC entry 3866 (class 0 OID 0)
  145. -- Dependencies: 211
  146. -- Name: obs_telemetry_obs_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  147. --
  148. ALTER SEQUENCE maplog.obs_telemetry_obs_id_seq OWNED BY maplog.obs_telemetry.obs_id;
  149. --
  150. -- TOC entry 209 (class 1259 OID 55579)
  151. -- Name: phenomenon; Type: TABLE; Schema: maplog; Owner: postgres
  152. --
  153. CREATE TABLE maplog.phenomenon (
  154. phenomenon_id integer NOT NULL,
  155. phenomenon_name text NOT NULL,
  156. uom character varying(30) NOT NULL,
  157. uom_link text
  158. );
  159. ALTER TABLE maplog.phenomenon OWNER TO senslog;
  160. --
  161. -- TOC entry 208 (class 1259 OID 55577)
  162. -- Name: phenomenon_phenomenon_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  163. --
  164. CREATE SEQUENCE maplog.phenomenon_phenomenon_id_seq
  165. AS integer
  166. START WITH 1
  167. INCREMENT BY 1
  168. NO MINVALUE
  169. NO MAXVALUE
  170. CACHE 1;
  171. ALTER TABLE maplog.phenomenon_phenomenon_id_seq OWNER TO senslog;
  172. --
  173. -- TOC entry 3867 (class 0 OID 0)
  174. -- Dependencies: 208
  175. -- Name: phenomenon_phenomenon_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  176. --
  177. ALTER SEQUENCE maplog.phenomenon_phenomenon_id_seq OWNED BY maplog.phenomenon.phenomenon_id;
  178. --
  179. -- TOC entry 207 (class 1259 OID 55566)
  180. -- Name: sensor; Type: TABLE; Schema: maplog; Owner: postgres
  181. --
  182. CREATE TABLE maplog.sensor (
  183. sensor_id bigint NOT NULL,
  184. sensor_name character varying(100),
  185. sensor_type text,
  186. sensor_type_id integer,
  187. min_range text,
  188. max_range text,
  189. phenomenon_id integer NOT NULL
  190. );
  191. ALTER TABLE maplog.sensor OWNER TO senslog;
  192. --
  193. -- TOC entry 206 (class 1259 OID 55564)
  194. -- Name: sensor_sensor_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  195. --
  196. CREATE SEQUENCE maplog.sensor_sensor_id_seq
  197. START WITH 1
  198. INCREMENT BY 1
  199. NO MINVALUE
  200. NO MAXVALUE
  201. CACHE 1;
  202. ALTER TABLE maplog.sensor_sensor_id_seq OWNER TO senslog;
  203. --
  204. -- TOC entry 3868 (class 0 OID 0)
  205. -- Dependencies: 206
  206. -- Name: sensor_sensor_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  207. --
  208. ALTER SEQUENCE maplog.sensor_sensor_id_seq OWNED BY maplog.sensor.sensor_id;
  209. --
  210. -- TOC entry 213 (class 1259 OID 55644)
  211. -- Name: system_user; Type: TABLE; Schema: maplog; Owner: postgres
  212. --
  213. CREATE TABLE maplog.system_user (
  214. user_id integer NOT NULL,
  215. user_name text NOT NULL,
  216. user_real_name text,
  217. user_password text,
  218. group_id integer,
  219. rights_id integer DEFAULT 0
  220. );
  221. ALTER TABLE maplog.system_user OWNER TO senslog;
  222. --
  223. -- TOC entry 204 (class 1259 OID 55540)
  224. -- Name: unit; Type: TABLE; Schema: maplog; Owner: postgres
  225. --
  226. CREATE TABLE maplog.unit (
  227. unit_id bigint NOT NULL,
  228. description text,
  229. is_mobile boolean DEFAULT true NOT NULL,
  230. unit_type_id character varying(2) DEFAULT 'X'::character varying NOT NULL
  231. );
  232. ALTER TABLE maplog.unit OWNER TO senslog;
  233. --
  234. -- TOC entry 218 (class 1259 OID 62712)
  235. -- Name: unit_to_campaign; Type: TABLE; Schema: maplog; Owner: postgres
  236. --
  237. CREATE TABLE maplog.unit_to_campaign (
  238. id integer NOT NULL,
  239. camp_id integer NOT NULL,
  240. unit_id bigint NOT NULL,
  241. from_time timestamp with time zone NOT NULL,
  242. to_time timestamp with time zone NOT NULL
  243. );
  244. ALTER TABLE maplog.unit_to_campaign OWNER TO senslog;
  245. --
  246. -- TOC entry 217 (class 1259 OID 62710)
  247. -- Name: unit_to_campaign_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  248. --
  249. CREATE SEQUENCE maplog.unit_to_campaign_id_seq
  250. AS integer
  251. START WITH 1
  252. INCREMENT BY 1
  253. NO MINVALUE
  254. NO MAXVALUE
  255. CACHE 1;
  256. ALTER TABLE maplog.unit_to_campaign_id_seq OWNER TO senslog;
  257. --
  258. -- TOC entry 3869 (class 0 OID 0)
  259. -- Dependencies: 217
  260. -- Name: unit_to_campaign_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  261. --
  262. ALTER SEQUENCE maplog.unit_to_campaign_id_seq OWNED BY maplog.unit_to_campaign.id;
  263. --
  264. -- TOC entry 226 (class 1259 OID 62796)
  265. -- Name: unit_to_group; Type: TABLE; Schema: maplog; Owner: postgres
  266. --
  267. CREATE TABLE maplog.unit_to_group (
  268. id integer NOT NULL,
  269. group_id integer,
  270. unit_id bigint
  271. );
  272. ALTER TABLE maplog.unit_to_group OWNER TO senslog;
  273. --
  274. -- TOC entry 225 (class 1259 OID 62794)
  275. -- Name: unit_to_group_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  276. --
  277. CREATE SEQUENCE maplog.unit_to_group_id_seq
  278. AS integer
  279. START WITH 1
  280. INCREMENT BY 1
  281. NO MINVALUE
  282. NO MAXVALUE
  283. CACHE 1;
  284. ALTER TABLE maplog.unit_to_group_id_seq OWNER TO senslog;
  285. --
  286. -- TOC entry 3870 (class 0 OID 0)
  287. -- Dependencies: 225
  288. -- Name: unit_to_group_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  289. --
  290. ALTER SEQUENCE maplog.unit_to_group_id_seq OWNED BY maplog.unit_to_group.id;
  291. --
  292. -- TOC entry 210 (class 1259 OID 55594)
  293. -- Name: unit_to_sensor; Type: TABLE; Schema: maplog; Owner: postgres
  294. --
  295. CREATE TABLE maplog.unit_to_sensor (
  296. sensor_id bigint NOT NULL,
  297. unit_id bigint NOT NULL,
  298. first_obs_ts timestamp with time zone,
  299. last_obs_ts timestamp with time zone,
  300. last_obs_value double precision DEFAULT 'NaN'::double precision
  301. );
  302. ALTER TABLE maplog.unit_to_sensor OWNER TO senslog;
  303. --
  304. -- TOC entry 205 (class 1259 OID 55548)
  305. -- Name: unit_type; Type: TABLE; Schema: maplog; Owner: postgres
  306. --
  307. CREATE TABLE maplog.unit_type (
  308. unit_type_id character varying(2) NOT NULL,
  309. type_name character varying(20) NOT NULL,
  310. description text
  311. );
  312. ALTER TABLE maplog.unit_type OWNER TO senslog;
  313. --
  314. -- TOC entry 214 (class 1259 OID 55654)
  315. -- Name: user_to_campaign; Type: TABLE; Schema: maplog; Owner: postgres
  316. --
  317. CREATE TABLE maplog.user_to_campaign (
  318. user_id integer NOT NULL,
  319. campaign_id integer NOT NULL
  320. );
  321. ALTER TABLE maplog.user_to_campaign OWNER TO senslog;
  322. --
  323. -- TOC entry 3638 (class 2604 OID 62704)
  324. -- Name: campaign campaign_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  325. --
  326. ALTER TABLE ONLY maplog.campaign ALTER COLUMN campaign_id SET DEFAULT nextval('maplog.campaign_campaign_id_seq'::regclass);
  327. --
  328. -- TOC entry 3643 (class 2604 OID 62787)
  329. -- Name: groups group_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  330. --
  331. ALTER TABLE ONLY maplog.groups ALTER COLUMN group_id SET DEFAULT nextval('maplog.group_group_id_seq'::regclass);
  332. --
  333. -- TOC entry 3635 (class 2604 OID 55617)
  334. -- Name: obs_telemetry obs_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  335. --
  336. ALTER TABLE ONLY maplog.obs_telemetry ALTER COLUMN obs_id SET DEFAULT nextval('maplog.obs_telemetry_obs_id_seq'::regclass);
  337. --
  338. -- TOC entry 3633 (class 2604 OID 55582)
  339. -- Name: phenomenon phenomenon_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  340. --
  341. ALTER TABLE ONLY maplog.phenomenon ALTER COLUMN phenomenon_id SET DEFAULT nextval('maplog.phenomenon_phenomenon_id_seq'::regclass);
  342. --
  343. -- TOC entry 3632 (class 2604 OID 55569)
  344. -- Name: sensor sensor_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  345. --
  346. ALTER TABLE ONLY maplog.sensor ALTER COLUMN sensor_id SET DEFAULT nextval('maplog.sensor_sensor_id_seq'::regclass);
  347. --
  348. -- TOC entry 3639 (class 2604 OID 62715)
  349. -- Name: unit_to_campaign id; Type: DEFAULT; Schema: maplog; Owner: postgres
  350. --
  351. ALTER TABLE ONLY maplog.unit_to_campaign ALTER COLUMN id SET DEFAULT nextval('maplog.unit_to_campaign_id_seq'::regclass);
  352. --
  353. -- TOC entry 3645 (class 2604 OID 62799)
  354. -- Name: unit_to_group id; Type: DEFAULT; Schema: maplog; Owner: postgres
  355. --
  356. ALTER TABLE ONLY maplog.unit_to_group ALTER COLUMN id SET DEFAULT nextval('maplog.unit_to_group_id_seq'::regclass);
  357. --
  358. -- TOC entry 3677 (class 2606 OID 62709)
  359. -- Name: campaign campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  360. --
  361. ALTER TABLE ONLY maplog.campaign
  362. ADD CONSTRAINT campaign_pkey PRIMARY KEY (campaign_id);
  363. --
  364. -- TOC entry 3689 (class 2606 OID 62793)
  365. -- Name: groups group_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  366. --
  367. ALTER TABLE ONLY maplog.groups
  368. ADD CONSTRAINT group_pkey PRIMARY KEY (group_id);
  369. --
  370. -- TOC entry 3667 (class 2606 OID 55623)
  371. -- Name: obs_telemetry obs_telemetry_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  372. --
  373. ALTER TABLE ONLY maplog.obs_telemetry
  374. ADD CONSTRAINT obs_telemetry_pkey PRIMARY KEY (obs_id);
  375. --
  376. -- TOC entry 3660 (class 2606 OID 55587)
  377. -- Name: phenomenon phenomenon_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  378. --
  379. ALTER TABLE ONLY maplog.phenomenon
  380. ADD CONSTRAINT phenomenon_pkey PRIMARY KEY (phenomenon_id);
  381. --
  382. -- TOC entry 3656 (class 2606 OID 55574)
  383. -- Name: sensor sensor_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  384. --
  385. ALTER TABLE ONLY maplog.sensor
  386. ADD CONSTRAINT sensor_pkey PRIMARY KEY (sensor_id);
  387. --
  388. -- TOC entry 3658 (class 2606 OID 55576)
  389. -- Name: sensor sensor_sensor_name_key; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  390. --
  391. ALTER TABLE ONLY maplog.sensor
  392. ADD CONSTRAINT sensor_sensor_name_key UNIQUE (sensor_name);
  393. --
  394. -- TOC entry 3670 (class 2606 OID 55653)
  395. -- Name: system_user systemuser_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  396. --
  397. ALTER TABLE ONLY maplog.system_user
  398. ADD CONSTRAINT systemuser_pk PRIMARY KEY (user_id);
  399. --
  400. -- TOC entry 3651 (class 2606 OID 55557)
  401. -- Name: unit unit_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  402. --
  403. ALTER TABLE ONLY maplog.unit
  404. ADD CONSTRAINT unit_pk PRIMARY KEY (unit_id);
  405. --
  406. -- TOC entry 3681 (class 2606 OID 62717)
  407. -- Name: unit_to_campaign unit_to_campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  408. --
  409. ALTER TABLE ONLY maplog.unit_to_campaign
  410. ADD CONSTRAINT unit_to_campaign_pkey PRIMARY KEY (id);
  411. --
  412. -- TOC entry 3693 (class 2606 OID 62801)
  413. -- Name: unit_to_group unit_to_group_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  414. --
  415. ALTER TABLE ONLY maplog.unit_to_group
  416. ADD CONSTRAINT unit_to_group_pkey PRIMARY KEY (id);
  417. --
  418. -- TOC entry 3653 (class 2606 OID 55555)
  419. -- Name: unit_type unittype_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  420. --
  421. ALTER TABLE ONLY maplog.unit_type
  422. ADD CONSTRAINT unittype_pk PRIMARY KEY (unit_type_id);
  423. --
  424. -- TOC entry 3675 (class 2606 OID 55658)
  425. -- Name: user_to_campaign user_to_campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  426. --
  427. ALTER TABLE ONLY maplog.user_to_campaign
  428. ADD CONSTRAINT user_to_campaign_pkey PRIMARY KEY (user_id, campaign_id);
  429. --
  430. -- TOC entry 3664 (class 2606 OID 55599)
  431. -- Name: unit_to_sensor uts_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  432. --
  433. ALTER TABLE ONLY maplog.unit_to_sensor
  434. ADD CONSTRAINT uts_pk PRIMARY KEY (unit_id, sensor_id);
  435. --
  436. -- TOC entry 3665 (class 1259 OID 55629)
  437. -- Name: fki_obss_unitid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  438. --
  439. CREATE INDEX fki_obss_unitid_fk ON maplog.obs_telemetry USING btree (unit_id);
  440. --
  441. -- TOC entry 3654 (class 1259 OID 55593)
  442. -- Name: fki_sens_phenom_fk; Type: INDEX; Schema: maplog; Owner: postgres
  443. --
  444. CREATE INDEX fki_sens_phenom_fk ON maplog.sensor USING btree (phenomenon_id);
  445. --
  446. -- TOC entry 3671 (class 1259 OID 62723)
  447. -- Name: fki_u2c_campid; Type: INDEX; Schema: maplog; Owner: postgres
  448. --
  449. CREATE INDEX fki_u2c_campid ON maplog.user_to_campaign USING btree (campaign_id);
  450. --
  451. -- TOC entry 3672 (class 1259 OID 55670)
  452. -- Name: fki_u2c_campid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  453. --
  454. CREATE INDEX fki_u2c_campid_fk ON maplog.user_to_campaign USING btree (campaign_id);
  455. --
  456. -- TOC entry 3673 (class 1259 OID 55664)
  457. -- Name: fki_u2c_userid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  458. --
  459. CREATE INDEX fki_u2c_userid_fk ON maplog.user_to_campaign USING btree (user_id);
  460. --
  461. -- TOC entry 3678 (class 1259 OID 62735)
  462. -- Name: fki_un2c_campid; Type: INDEX; Schema: maplog; Owner: postgres
  463. --
  464. CREATE INDEX fki_un2c_campid ON maplog.unit_to_campaign USING btree (camp_id);
  465. --
  466. -- TOC entry 3679 (class 1259 OID 62729)
  467. -- Name: fki_un2c_unitid; Type: INDEX; Schema: maplog; Owner: postgres
  468. --
  469. CREATE INDEX fki_un2c_unitid ON maplog.unit_to_campaign USING btree (unit_id);
  470. --
  471. -- TOC entry 3690 (class 1259 OID 62813)
  472. -- Name: fki_unit2group_group_fk; Type: INDEX; Schema: maplog; Owner: postgres
  473. --
  474. CREATE INDEX fki_unit2group_group_fk ON maplog.unit_to_group USING btree (group_id);
  475. --
  476. -- TOC entry 3691 (class 1259 OID 62819)
  477. -- Name: fki_unit2group_unit_fk; Type: INDEX; Schema: maplog; Owner: postgres
  478. --
  479. CREATE INDEX fki_unit2group_unit_fk ON maplog.unit_to_group USING btree (unit_id);
  480. --
  481. -- TOC entry 3649 (class 1259 OID 55563)
  482. -- Name: fki_unit_unittype_fk; Type: INDEX; Schema: maplog; Owner: postgres
  483. --
  484. CREATE INDEX fki_unit_unittype_fk ON maplog.unit USING btree (unit_type_id);
  485. --
  486. -- TOC entry 3668 (class 1259 OID 62807)
  487. -- Name: fki_user2group_fk; Type: INDEX; Schema: maplog; Owner: postgres
  488. --
  489. CREATE INDEX fki_user2group_fk ON maplog.system_user USING btree (group_id);
  490. --
  491. -- TOC entry 3661 (class 1259 OID 55611)
  492. -- Name: fki_uts_sensorid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  493. --
  494. CREATE INDEX fki_uts_sensorid_fk ON maplog.unit_to_sensor USING btree (sensor_id);
  495. --
  496. -- TOC entry 3662 (class 1259 OID 55605)
  497. -- Name: fki_uts_unitid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  498. --
  499. CREATE INDEX fki_uts_unitid_fk ON maplog.unit_to_sensor USING btree (unit_id);
  500. --
  501. -- TOC entry 3700 (class 2606 OID 55624)
  502. -- Name: obs_telemetry obss_unitid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  503. --
  504. ALTER TABLE ONLY maplog.obs_telemetry
  505. ADD CONSTRAINT obss_unitid_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  506. --
  507. -- TOC entry 3697 (class 2606 OID 55588)
  508. -- Name: sensor sens_phenom_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  509. --
  510. ALTER TABLE ONLY maplog.sensor
  511. ADD CONSTRAINT sens_phenom_fk FOREIGN KEY (phenomenon_id) REFERENCES maplog.phenomenon(phenomenon_id);
  512. --
  513. -- TOC entry 3702 (class 2606 OID 62718)
  514. -- Name: user_to_campaign u2c_campid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  515. --
  516. ALTER TABLE ONLY maplog.user_to_campaign
  517. ADD CONSTRAINT u2c_campid FOREIGN KEY (campaign_id) REFERENCES maplog.campaign(campaign_id) ON UPDATE CASCADE ON DELETE CASCADE;
  518. --
  519. -- TOC entry 3703 (class 2606 OID 55659)
  520. -- Name: user_to_campaign u2c_userid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  521. --
  522. ALTER TABLE ONLY maplog.user_to_campaign
  523. ADD CONSTRAINT u2c_userid_fk FOREIGN KEY (user_id) REFERENCES maplog.system_user(user_id) ON UPDATE CASCADE ON DELETE CASCADE;
  524. --
  525. -- TOC entry 3704 (class 2606 OID 62730)
  526. -- Name: unit_to_campaign un2c_campid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  527. --
  528. ALTER TABLE ONLY maplog.unit_to_campaign
  529. ADD CONSTRAINT un2c_campid FOREIGN KEY (camp_id) REFERENCES maplog.campaign(campaign_id) ON UPDATE CASCADE ON DELETE CASCADE;
  530. --
  531. -- TOC entry 3705 (class 2606 OID 62724)
  532. -- Name: unit_to_campaign un2c_unitid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  533. --
  534. ALTER TABLE ONLY maplog.unit_to_campaign
  535. ADD CONSTRAINT un2c_unitid FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  536. --
  537. -- TOC entry 3706 (class 2606 OID 62808)
  538. -- Name: unit_to_group unit2group_group_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  539. --
  540. ALTER TABLE ONLY maplog.unit_to_group
  541. ADD CONSTRAINT unit2group_group_fk FOREIGN KEY (group_id) REFERENCES maplog.groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  542. --
  543. -- TOC entry 3707 (class 2606 OID 62814)
  544. -- Name: unit_to_group unit2group_unit_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  545. --
  546. ALTER TABLE ONLY maplog.unit_to_group
  547. ADD CONSTRAINT unit2group_unit_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  548. --
  549. -- TOC entry 3696 (class 2606 OID 55558)
  550. -- Name: unit unit_unittype_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  551. --
  552. ALTER TABLE ONLY maplog.unit
  553. ADD CONSTRAINT unit_unittype_fk FOREIGN KEY (unit_type_id) REFERENCES maplog.unit_type(unit_type_id);
  554. --
  555. -- TOC entry 3701 (class 2606 OID 62802)
  556. -- Name: system_user user2group_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  557. --
  558. ALTER TABLE ONLY maplog.system_user
  559. ADD CONSTRAINT user2group_fk FOREIGN KEY (group_id) REFERENCES maplog.groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  560. --
  561. -- TOC entry 3698 (class 2606 OID 55606)
  562. -- Name: unit_to_sensor uts_sensorid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  563. --
  564. ALTER TABLE ONLY maplog.unit_to_sensor
  565. ADD CONSTRAINT uts_sensorid_fk FOREIGN KEY (sensor_id) REFERENCES maplog.sensor(sensor_id) ON UPDATE CASCADE ON DELETE CASCADE;
  566. --
  567. -- TOC entry 3699 (class 2606 OID 55600)
  568. -- Name: unit_to_sensor uts_unitid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  569. --
  570. ALTER TABLE ONLY maplog.unit_to_sensor
  571. ADD CONSTRAINT uts_unitid_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  572. --
  573. -- TOC entry 3862 (class 0 OID 0)
  574. -- Dependencies: 7
  575. -- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
  576. --
  577. REVOKE USAGE ON SCHEMA public FROM PUBLIC;
  578. GRANT ALL ON SCHEMA public TO PUBLIC;
  579. -- Completed on 2023-05-05 01:10:04
  580. --
  581. -- PostgreSQL database dump complete
  582. --