--
-- PostgreSQL database dump
--

-- Dumped from database version 12devel
-- Dumped by pg_dump version 12devel

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: events; Type: TABLE; Schema: public; Owner: maksim
--

CREATE TABLE public.events (
    eventid bigint NOT NULL,
    source integer DEFAULT 0 NOT NULL,
    object integer DEFAULT 0 NOT NULL,
    objectid bigint DEFAULT (0)::bigint NOT NULL,
    clock integer DEFAULT 0 NOT NULL,
    value integer DEFAULT 0 NOT NULL,
    acknowledged integer DEFAULT 0 NOT NULL,
    ns integer DEFAULT 0 NOT NULL
);


ALTER TABLE public.events OWNER TO maksim;

--
-- Name: functions; Type: TABLE; Schema: public; Owner: maksim
--

CREATE TABLE public.functions (
    functionid bigint NOT NULL,
    itemid bigint NOT NULL,
    triggerid bigint NOT NULL,
    function character varying(12) DEFAULT ''::character varying NOT NULL,
    parameter character varying(255) DEFAULT '0'::character varying NOT NULL
);


ALTER TABLE public.functions OWNER TO maksim;

--
-- Name: items; Type: TABLE; Schema: public; Owner: maksim
--

CREATE TABLE public.items (
    itemid bigint NOT NULL,
    hostid bigint NOT NULL,
    key_ character varying(255) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE public.items OWNER TO maksim;

--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: maksim
--

ALTER TABLE ONLY public.events
    ADD CONSTRAINT events_pkey PRIMARY KEY (eventid);


--
-- Name: functions functions_pkey; Type: CONSTRAINT; Schema: public; Owner: maksim
--

ALTER TABLE ONLY public.functions
    ADD CONSTRAINT functions_pkey PRIMARY KEY (functionid);


--
-- Name: items items_pkey; Type: CONSTRAINT; Schema: public; Owner: maksim
--

ALTER TABLE ONLY public.items
    ADD CONSTRAINT items_pkey PRIMARY KEY (itemid);


--
-- Name: event_1; Type: INDEX; Schema: public; Owner: maksim
--

CREATE INDEX event_1 ON public.events USING btree (source, object, objectid, clock);


--
-- Name: event_2; Type: INDEX; Schema: public; Owner: maksim
--

CREATE INDEX event_2 ON public.events USING btree (source, object, clock);


--
-- Name: functions_1; Type: INDEX; Schema: public; Owner: maksim
--

CREATE INDEX functions_1 ON public.functions USING btree (triggerid);


--
-- Name: functions_2; Type: INDEX; Schema: public; Owner: maksim
--

CREATE INDEX functions_2 ON public.functions USING btree (itemid, function, parameter);


--
-- Name: items_1; Type: INDEX; Schema: public; Owner: maksim
--

CREATE INDEX items_1 ON public.items USING btree (hostid, key_);


--
-- Name: functions c_functions_1; Type: FK CONSTRAINT; Schema: public; Owner: maksim
--

ALTER TABLE ONLY public.functions
    ADD CONSTRAINT c_functions_1 FOREIGN KEY (itemid) REFERENCES public.items(itemid) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

