init.sql 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  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. imei character varying(20) NOT NULL,
  229. description text,
  230. is_mobile boolean DEFAULT true NOT NULL,
  231. unit_type_id character varying(2) DEFAULT 'X'::character varying NOT NULL
  232. );
  233. ALTER TABLE maplog.unit OWNER TO senslog;
  234. --
  235. -- TOC entry 218 (class 1259 OID 62712)
  236. -- Name: unit_to_campaign; Type: TABLE; Schema: maplog; Owner: postgres
  237. --
  238. CREATE TABLE maplog.unit_to_campaign (
  239. id integer NOT NULL,
  240. camp_id integer NOT NULL,
  241. unit_id bigint NOT NULL,
  242. from_time timestamp with time zone NOT NULL,
  243. to_time timestamp with time zone NOT NULL
  244. );
  245. ALTER TABLE maplog.unit_to_campaign OWNER TO senslog;
  246. --
  247. -- TOC entry 217 (class 1259 OID 62710)
  248. -- Name: unit_to_campaign_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  249. --
  250. CREATE SEQUENCE maplog.unit_to_campaign_id_seq
  251. AS integer
  252. START WITH 1
  253. INCREMENT BY 1
  254. NO MINVALUE
  255. NO MAXVALUE
  256. CACHE 1;
  257. ALTER TABLE maplog.unit_to_campaign_id_seq OWNER TO senslog;
  258. --
  259. -- TOC entry 3869 (class 0 OID 0)
  260. -- Dependencies: 217
  261. -- Name: unit_to_campaign_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  262. --
  263. ALTER SEQUENCE maplog.unit_to_campaign_id_seq OWNED BY maplog.unit_to_campaign.id;
  264. --
  265. -- TOC entry 226 (class 1259 OID 62796)
  266. -- Name: unit_to_group; Type: TABLE; Schema: maplog; Owner: postgres
  267. --
  268. CREATE TABLE maplog.unit_to_group (
  269. id integer NOT NULL,
  270. group_id integer,
  271. unit_id bigint
  272. );
  273. ALTER TABLE maplog.unit_to_group OWNER TO senslog;
  274. --
  275. -- TOC entry 225 (class 1259 OID 62794)
  276. -- Name: unit_to_group_id_seq; Type: SEQUENCE; Schema: maplog; Owner: postgres
  277. --
  278. CREATE SEQUENCE maplog.unit_to_group_id_seq
  279. AS integer
  280. START WITH 1
  281. INCREMENT BY 1
  282. NO MINVALUE
  283. NO MAXVALUE
  284. CACHE 1;
  285. ALTER TABLE maplog.unit_to_group_id_seq OWNER TO senslog;
  286. --
  287. -- TOC entry 3870 (class 0 OID 0)
  288. -- Dependencies: 225
  289. -- Name: unit_to_group_id_seq; Type: SEQUENCE OWNED BY; Schema: maplog; Owner: postgres
  290. --
  291. ALTER SEQUENCE maplog.unit_to_group_id_seq OWNED BY maplog.unit_to_group.id;
  292. --
  293. -- TOC entry 210 (class 1259 OID 55594)
  294. -- Name: unit_to_sensor; Type: TABLE; Schema: maplog; Owner: postgres
  295. --
  296. CREATE TABLE maplog.unit_to_sensor (
  297. sensor_id bigint NOT NULL,
  298. unit_id bigint NOT NULL,
  299. first_obs_ts timestamp with time zone,
  300. last_obs_ts timestamp with time zone,
  301. last_obs_value double precision DEFAULT 'NaN'::double precision
  302. );
  303. ALTER TABLE maplog.unit_to_sensor OWNER TO senslog;
  304. --
  305. -- TOC entry 205 (class 1259 OID 55548)
  306. -- Name: unit_type; Type: TABLE; Schema: maplog; Owner: postgres
  307. --
  308. CREATE TABLE maplog.unit_type (
  309. unit_type_id character varying(2) NOT NULL,
  310. type_name character varying(20) NOT NULL,
  311. description text
  312. );
  313. ALTER TABLE maplog.unit_type OWNER TO senslog;
  314. --
  315. -- TOC entry 214 (class 1259 OID 55654)
  316. -- Name: user_to_campaign; Type: TABLE; Schema: maplog; Owner: postgres
  317. --
  318. CREATE TABLE maplog.user_to_campaign (
  319. user_id integer NOT NULL,
  320. campaign_id integer NOT NULL
  321. );
  322. ALTER TABLE maplog.user_to_campaign OWNER TO senslog;
  323. --
  324. -- TOC entry 3638 (class 2604 OID 62704)
  325. -- Name: campaign campaign_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  326. --
  327. ALTER TABLE ONLY maplog.campaign ALTER COLUMN campaign_id SET DEFAULT nextval('maplog.campaign_campaign_id_seq'::regclass);
  328. --
  329. -- TOC entry 3643 (class 2604 OID 62787)
  330. -- Name: groups group_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  331. --
  332. ALTER TABLE ONLY maplog.groups ALTER COLUMN group_id SET DEFAULT nextval('maplog.group_group_id_seq'::regclass);
  333. --
  334. -- TOC entry 3635 (class 2604 OID 55617)
  335. -- Name: obs_telemetry obs_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  336. --
  337. ALTER TABLE ONLY maplog.obs_telemetry ALTER COLUMN obs_id SET DEFAULT nextval('maplog.obs_telemetry_obs_id_seq'::regclass);
  338. --
  339. -- TOC entry 3633 (class 2604 OID 55582)
  340. -- Name: phenomenon phenomenon_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  341. --
  342. ALTER TABLE ONLY maplog.phenomenon ALTER COLUMN phenomenon_id SET DEFAULT nextval('maplog.phenomenon_phenomenon_id_seq'::regclass);
  343. --
  344. -- TOC entry 3632 (class 2604 OID 55569)
  345. -- Name: sensor sensor_id; Type: DEFAULT; Schema: maplog; Owner: postgres
  346. --
  347. ALTER TABLE ONLY maplog.sensor ALTER COLUMN sensor_id SET DEFAULT nextval('maplog.sensor_sensor_id_seq'::regclass);
  348. --
  349. -- TOC entry 3639 (class 2604 OID 62715)
  350. -- Name: unit_to_campaign id; Type: DEFAULT; Schema: maplog; Owner: postgres
  351. --
  352. ALTER TABLE ONLY maplog.unit_to_campaign ALTER COLUMN id SET DEFAULT nextval('maplog.unit_to_campaign_id_seq'::regclass);
  353. --
  354. -- TOC entry 3645 (class 2604 OID 62799)
  355. -- Name: unit_to_group id; Type: DEFAULT; Schema: maplog; Owner: postgres
  356. --
  357. ALTER TABLE ONLY maplog.unit_to_group ALTER COLUMN id SET DEFAULT nextval('maplog.unit_to_group_id_seq'::regclass);
  358. --
  359. -- TOC entry 3677 (class 2606 OID 62709)
  360. -- Name: campaign campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  361. --
  362. ALTER TABLE ONLY maplog.campaign
  363. ADD CONSTRAINT campaign_pkey PRIMARY KEY (campaign_id);
  364. --
  365. -- TOC entry 3689 (class 2606 OID 62793)
  366. -- Name: groups group_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  367. --
  368. ALTER TABLE ONLY maplog.groups
  369. ADD CONSTRAINT group_pkey PRIMARY KEY (group_id);
  370. --
  371. -- TOC entry 3667 (class 2606 OID 55623)
  372. -- Name: obs_telemetry obs_telemetry_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  373. --
  374. ALTER TABLE ONLY maplog.obs_telemetry
  375. ADD CONSTRAINT obs_telemetry_pkey PRIMARY KEY (obs_id);
  376. --
  377. -- TOC entry 3660 (class 2606 OID 55587)
  378. -- Name: phenomenon phenomenon_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  379. --
  380. ALTER TABLE ONLY maplog.phenomenon
  381. ADD CONSTRAINT phenomenon_pkey PRIMARY KEY (phenomenon_id);
  382. --
  383. -- TOC entry 3656 (class 2606 OID 55574)
  384. -- Name: sensor sensor_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  385. --
  386. ALTER TABLE ONLY maplog.sensor
  387. ADD CONSTRAINT sensor_pkey PRIMARY KEY (sensor_id);
  388. --
  389. -- TOC entry 3658 (class 2606 OID 55576)
  390. -- Name: sensor sensor_sensor_name_key; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  391. --
  392. ALTER TABLE ONLY maplog.sensor
  393. ADD CONSTRAINT sensor_sensor_name_key UNIQUE (sensor_name);
  394. --
  395. -- TOC entry 3670 (class 2606 OID 55653)
  396. -- Name: system_user systemuser_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  397. --
  398. ALTER TABLE ONLY maplog.system_user
  399. ADD CONSTRAINT systemuser_pk PRIMARY KEY (user_id);
  400. --
  401. -- TOC entry 3651 (class 2606 OID 55557)
  402. -- Name: unit unit_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  403. --
  404. ALTER TABLE ONLY maplog.unit
  405. ADD CONSTRAINT unit_pk PRIMARY KEY (unit_id);
  406. --
  407. -- TOC entry 3681 (class 2606 OID 62717)
  408. -- Name: unit_to_campaign unit_to_campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  409. --
  410. ALTER TABLE ONLY maplog.unit_to_campaign
  411. ADD CONSTRAINT unit_to_campaign_pkey PRIMARY KEY (id);
  412. --
  413. -- TOC entry 3693 (class 2606 OID 62801)
  414. -- Name: unit_to_group unit_to_group_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  415. --
  416. ALTER TABLE ONLY maplog.unit_to_group
  417. ADD CONSTRAINT unit_to_group_pkey PRIMARY KEY (id);
  418. --
  419. -- TOC entry 3653 (class 2606 OID 55555)
  420. -- Name: unit_type unittype_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  421. --
  422. ALTER TABLE ONLY maplog.unit_type
  423. ADD CONSTRAINT unittype_pk PRIMARY KEY (unit_type_id);
  424. --
  425. -- TOC entry 3675 (class 2606 OID 55658)
  426. -- Name: user_to_campaign user_to_campaign_pkey; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  427. --
  428. ALTER TABLE ONLY maplog.user_to_campaign
  429. ADD CONSTRAINT user_to_campaign_pkey PRIMARY KEY (user_id, campaign_id);
  430. --
  431. -- TOC entry 3664 (class 2606 OID 55599)
  432. -- Name: unit_to_sensor uts_pk; Type: CONSTRAINT; Schema: maplog; Owner: postgres
  433. --
  434. ALTER TABLE ONLY maplog.unit_to_sensor
  435. ADD CONSTRAINT uts_pk PRIMARY KEY (unit_id, sensor_id);
  436. --
  437. -- TOC entry 3665 (class 1259 OID 55629)
  438. -- Name: fki_obss_unitid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  439. --
  440. CREATE INDEX fki_obss_unitid_fk ON maplog.obs_telemetry USING btree (unit_id);
  441. --
  442. -- TOC entry 3654 (class 1259 OID 55593)
  443. -- Name: fki_sens_phenom_fk; Type: INDEX; Schema: maplog; Owner: postgres
  444. --
  445. CREATE INDEX fki_sens_phenom_fk ON maplog.sensor USING btree (phenomenon_id);
  446. --
  447. -- TOC entry 3671 (class 1259 OID 62723)
  448. -- Name: fki_u2c_campid; Type: INDEX; Schema: maplog; Owner: postgres
  449. --
  450. CREATE INDEX fki_u2c_campid ON maplog.user_to_campaign USING btree (campaign_id);
  451. --
  452. -- TOC entry 3672 (class 1259 OID 55670)
  453. -- Name: fki_u2c_campid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  454. --
  455. CREATE INDEX fki_u2c_campid_fk ON maplog.user_to_campaign USING btree (campaign_id);
  456. --
  457. -- TOC entry 3673 (class 1259 OID 55664)
  458. -- Name: fki_u2c_userid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  459. --
  460. CREATE INDEX fki_u2c_userid_fk ON maplog.user_to_campaign USING btree (user_id);
  461. --
  462. -- TOC entry 3678 (class 1259 OID 62735)
  463. -- Name: fki_un2c_campid; Type: INDEX; Schema: maplog; Owner: postgres
  464. --
  465. CREATE INDEX fki_un2c_campid ON maplog.unit_to_campaign USING btree (camp_id);
  466. --
  467. -- TOC entry 3679 (class 1259 OID 62729)
  468. -- Name: fki_un2c_unitid; Type: INDEX; Schema: maplog; Owner: postgres
  469. --
  470. CREATE INDEX fki_un2c_unitid ON maplog.unit_to_campaign USING btree (unit_id);
  471. --
  472. -- TOC entry 3690 (class 1259 OID 62813)
  473. -- Name: fki_unit2group_group_fk; Type: INDEX; Schema: maplog; Owner: postgres
  474. --
  475. CREATE INDEX fki_unit2group_group_fk ON maplog.unit_to_group USING btree (group_id);
  476. --
  477. -- TOC entry 3691 (class 1259 OID 62819)
  478. -- Name: fki_unit2group_unit_fk; Type: INDEX; Schema: maplog; Owner: postgres
  479. --
  480. CREATE INDEX fki_unit2group_unit_fk ON maplog.unit_to_group USING btree (unit_id);
  481. --
  482. -- TOC entry 3649 (class 1259 OID 55563)
  483. -- Name: fki_unit_unittype_fk; Type: INDEX; Schema: maplog; Owner: postgres
  484. --
  485. CREATE INDEX fki_unit_unittype_fk ON maplog.unit USING btree (unit_type_id);
  486. --
  487. -- TOC entry 3668 (class 1259 OID 62807)
  488. -- Name: fki_user2group_fk; Type: INDEX; Schema: maplog; Owner: postgres
  489. --
  490. CREATE INDEX fki_user2group_fk ON maplog.system_user USING btree (group_id);
  491. --
  492. -- TOC entry 3661 (class 1259 OID 55611)
  493. -- Name: fki_uts_sensorid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  494. --
  495. CREATE INDEX fki_uts_sensorid_fk ON maplog.unit_to_sensor USING btree (sensor_id);
  496. --
  497. -- TOC entry 3662 (class 1259 OID 55605)
  498. -- Name: fki_uts_unitid_fk; Type: INDEX; Schema: maplog; Owner: postgres
  499. --
  500. CREATE INDEX fki_uts_unitid_fk ON maplog.unit_to_sensor USING btree (unit_id);
  501. --
  502. -- TOC entry 3700 (class 2606 OID 55624)
  503. -- Name: obs_telemetry obss_unitid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  504. --
  505. ALTER TABLE ONLY maplog.obs_telemetry
  506. ADD CONSTRAINT obss_unitid_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  507. --
  508. -- TOC entry 3697 (class 2606 OID 55588)
  509. -- Name: sensor sens_phenom_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  510. --
  511. ALTER TABLE ONLY maplog.sensor
  512. ADD CONSTRAINT sens_phenom_fk FOREIGN KEY (phenomenon_id) REFERENCES maplog.phenomenon(phenomenon_id);
  513. --
  514. -- TOC entry 3702 (class 2606 OID 62718)
  515. -- Name: user_to_campaign u2c_campid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  516. --
  517. ALTER TABLE ONLY maplog.user_to_campaign
  518. ADD CONSTRAINT u2c_campid FOREIGN KEY (campaign_id) REFERENCES maplog.campaign(campaign_id) ON UPDATE CASCADE ON DELETE CASCADE;
  519. --
  520. -- TOC entry 3703 (class 2606 OID 55659)
  521. -- Name: user_to_campaign u2c_userid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  522. --
  523. ALTER TABLE ONLY maplog.user_to_campaign
  524. ADD CONSTRAINT u2c_userid_fk FOREIGN KEY (user_id) REFERENCES maplog.system_user(user_id) ON UPDATE CASCADE ON DELETE CASCADE;
  525. --
  526. -- TOC entry 3704 (class 2606 OID 62730)
  527. -- Name: unit_to_campaign un2c_campid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  528. --
  529. ALTER TABLE ONLY maplog.unit_to_campaign
  530. ADD CONSTRAINT un2c_campid FOREIGN KEY (camp_id) REFERENCES maplog.campaign(campaign_id) ON UPDATE CASCADE ON DELETE CASCADE;
  531. --
  532. -- TOC entry 3705 (class 2606 OID 62724)
  533. -- Name: unit_to_campaign un2c_unitid; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  534. --
  535. ALTER TABLE ONLY maplog.unit_to_campaign
  536. ADD CONSTRAINT un2c_unitid FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  537. --
  538. -- TOC entry 3706 (class 2606 OID 62808)
  539. -- Name: unit_to_group unit2group_group_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  540. --
  541. ALTER TABLE ONLY maplog.unit_to_group
  542. ADD CONSTRAINT unit2group_group_fk FOREIGN KEY (group_id) REFERENCES maplog.groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  543. --
  544. -- TOC entry 3707 (class 2606 OID 62814)
  545. -- Name: unit_to_group unit2group_unit_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  546. --
  547. ALTER TABLE ONLY maplog.unit_to_group
  548. ADD CONSTRAINT unit2group_unit_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  549. --
  550. -- TOC entry 3696 (class 2606 OID 55558)
  551. -- Name: unit unit_unittype_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  552. --
  553. ALTER TABLE ONLY maplog.unit
  554. ADD CONSTRAINT unit_unittype_fk FOREIGN KEY (unit_type_id) REFERENCES maplog.unit_type(unit_type_id);
  555. --
  556. -- TOC entry 3701 (class 2606 OID 62802)
  557. -- Name: system_user user2group_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  558. --
  559. ALTER TABLE ONLY maplog.system_user
  560. ADD CONSTRAINT user2group_fk FOREIGN KEY (group_id) REFERENCES maplog.groups(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  561. --
  562. -- TOC entry 3698 (class 2606 OID 55606)
  563. -- Name: unit_to_sensor uts_sensorid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  564. --
  565. ALTER TABLE ONLY maplog.unit_to_sensor
  566. ADD CONSTRAINT uts_sensorid_fk FOREIGN KEY (sensor_id) REFERENCES maplog.sensor(sensor_id) ON UPDATE CASCADE ON DELETE CASCADE;
  567. --
  568. -- TOC entry 3699 (class 2606 OID 55600)
  569. -- Name: unit_to_sensor uts_unitid_fk; Type: FK CONSTRAINT; Schema: maplog; Owner: postgres
  570. --
  571. ALTER TABLE ONLY maplog.unit_to_sensor
  572. ADD CONSTRAINT uts_unitid_fk FOREIGN KEY (unit_id) REFERENCES maplog.unit(unit_id) ON UPDATE CASCADE ON DELETE CASCADE;
  573. --
  574. -- TOC entry 3862 (class 0 OID 0)
  575. -- Dependencies: 7
  576. -- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
  577. --
  578. REVOKE USAGE ON SCHEMA public FROM PUBLIC;
  579. GRANT ALL ON SCHEMA public TO PUBLIC;
  580. -- Completed on 2023-05-05 01:10:04
  581. --
  582. -- PostgreSQL database dump complete
  583. --