--
-- PostgreSQL database dump
--


SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

drop database if exists thundersnarf;
DROP ROLE IF EXISTS thundersnarf;

CREATE ROLE thundersnarf PASSWORD 'thundercachesnarf' CREATEDB VALID UNTIL 'infinity' LOGIN;
create database thundersnarf owner thundersnarf;

\connect thundersnarf pgsql;

--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pgsql
--

COMMENT ON SCHEMA public IS 'Standard public schema';


--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: pgsql
--

CREATE PROCEDURAL LANGUAGE plpgsql;


SET search_path = public, pg_catalog;

--
-- Name: insertfile(integer, character varying, character varying, bigint, bigint, character varying, character varying, character varying, character varying, boolean, boolean, character varying); Type: FUNCTION; Schema: public; Owner: thundersnarf
--

CREATE FUNCTION insertfile(integer, character varying, character varying, bigint, bigint, character varying, character varying, character varying, character varying, boolean, boolean, character varying) RETURNS boolean
    AS $_$DECLARE d record; f record; e record; i record; di record; dt record; timestamp_1 integer; ip_2 character varying; response_3 character varying; filesize_4 bigint; transfered_5 bigint; type_of_request_6 character varying; url_7 character varying; domain_8 character varying; file_9 character varying; static_10 bool; hit_11 bool; extension_12 character varying; incrementa_static integer;
 BEGIN
    timestamp_1 = $1;
    ip_2 = $2;
    response_3 = $3;
    filesize_4 = $4;
    transfered_5 = $5;
    type_of_request_6 = $6;
    url_7 = $7;
    domain_8 = $8;
    file_9 = $9;
    static_10 = $10;
    hit_11 = $11;
    extension_12 = $12;
    SELECT INTO d id
    FROM thundersnarf_domain
    WHERE domain = domain_8;
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_domain(domain, last_requested) values(domain_8, timestamp_1) RETURNING id INTO d;
            EXCEPTION WHEN unique_violation THEN
                SELECT into d id 
                FROM thundersnarf_domain 
                WHERE domain = domain_8;
        END;
    END IF;
    SELECT INTO f id
    FROM thundersnarf_file
    WHERE domain_id = d.id AND file = file_9;
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_file(domain_id, url, file, size, extension, downloaded, last_requested) values(d.id, url_7, file_9, filesize_4, extension_12, timestamp_1, timestamp_1) RETURNING id INTO f;
            EXCEPTION WHEN unique_violation THEN
                SELECT INTO f id
                FROM thundersnarf_file
                WHERE domain_id = d AND file = file_9;
        END;
    END IF;
    SELECT INTO e id
    FROM thundersnarf_extension
    WHERE extension = extension_12;
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_extension(extension, last_requested) values(extension_12, timestamp_1) RETURNING id INTO e;
            EXCEPTION WHEN unique_violation THEN
                SELECT INTO e id
                FROM thundersnarf_extension
                WHERE extension = extension_12;
        END;
    END IF;
    SELECT INTO i id
    FROM thundersnarf_ip
    WHERE ip = ip_2;
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_ip(ip, last_requested) values(ip_2, timestamp_1) RETURNING id INTO i;
            EXCEPTION WHEN unique_violation THEN
                SELECT INTO i id
                FROM thundersnarf_ip
                WHERE ip = ip_2;
        END;
    END IF;
    SELECT INTO di domain_id
    FROM thundersnarf_domainip
    WHERE domain_id = d.id AND ip_id = i.id;
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_domainip(domain_id,ip_id, last_requested) values(d.id, i.id, timestamp_1) RETURNING domain_id INTO di;
            EXCEPTION WHEN unique_violation THEN
                SELECT INTO di domain_id
                FROM thundersnarf_domainip
                WHERE domain_id = d.id AND ip_id = i.id;
        END;
    END IF;
    SELECT INTO dt id_data
    FROM thundersnarf_data
    WHERE id_data = to_number(to_char(to_timestamp(timestamp_1),'yyyymmdd'),'99999999');
    IF not found THEN
        BEGIN
            INSERT INTO thundersnarf_data(id_data) values(to_number(to_char(to_timestamp(timestamp_1),'yyyymmdd'),'99999999')) RETURNING id_data INTO dt;
            EXCEPTION WHEN unique_violation THEN
                SELECT INTO dt id_data
                FROM thundersnarf_data
                WHERE id_data = to_number(to_char(to_timestamp(timestamp_1),'yyyymmdd'),'99999999');
        END;
    END IF;
    IF static_10 THEN
        IF hit_11 THEN
            UPDATE thundersnarf_domain SET requested=requested+1, last_requested=timestamp_1, cache_static=cache_static+transfered_5, hit_static=hit_static+1 WHERE id=d.id;
            UPDATE thundersnarf_extension SET requested=requested+1, last_requested=timestamp_1, cache_static=cache_static+transfered_5, hit_static=hit_static+1, last_url=url_7 WHERE id=e.id;
            UPDATE thundersnarf_ip SET requested=requested+1, last_requested=timestamp_1, cache_static=cache_static+transfered_5, hit_static=hit_static+1 WHERE id=i.id;
            UPDATE thundersnarf_domainip SET requested=requested+1, last_requested=timestamp_1, cache_static=cache_static+transfered_5, hit_static=hit_static+1 WHERE domain_id=d.id AND ip_id = i.id;
            UPDATE thundersnarf_data SET requested=requested+1, cache_static=cache_static+transfered_5, hit_static=hit_static+1 WHERE id_data=dt.id_data;
            UPDATE thundersnarf_file SET requested=requested+1, size=filesize_4, last_requested=timestamp_1, cache_static=cache_static+transfered_5, hit_static=hit_static+1 WHERE id=f.id;
        ELSE
            UPDATE thundersnarf_domain SET requested=requested+1, last_requested=timestamp_1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1 WHERE id=d.id;
            UPDATE thundersnarf_extension SET requested=requested+1, last_requested=timestamp_1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1, last_url=url_7  WHERE id=e.id;
            UPDATE thundersnarf_ip SET requested=requested+1, last_requested=timestamp_1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1  WHERE id=i.id;
            UPDATE thundersnarf_domainip SET requested=requested+1, last_requested=timestamp_1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1  WHERE domain_id=d.id AND ip_id = i.id;
            UPDATE thundersnarf_data SET requested=requested+1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1  WHERE id_data=dt.id_data;
            UPDATE thundersnarf_file SET requested=requested+1, size=filesize_4, last_requested=timestamp_1, traffic_static=traffic_static+transfered_5, miss_static=miss_static+1 WHERE id=f.id;
        END IF;
    ELSE
        IF hit_11 THEN
            UPDATE thundersnarf_domain SET requested=requested+1, last_requested=timestamp_1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1 WHERE id=d.id;
            UPDATE thundersnarf_extension SET requested=requested+1, last_requested=timestamp_1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1, last_url=url_7 WHERE id=e.id;
            UPDATE thundersnarf_ip SET requested=requested+1, last_requested=timestamp_1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1 WHERE id=i.id;
            UPDATE thundersnarf_domainip SET requested=requested+1, last_requested=timestamp_1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1 WHERE domain_id=d.id AND ip_id = i.id;
            UPDATE thundersnarf_data SET requested=requested+1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1 WHERE id_data=dt.id_data;
            UPDATE thundersnarf_file SET requested=requested+1, size=filesize_4, last_requested=timestamp_1, cache_dynamic=cache_dynamic+transfered_5, hit_dynamic=hit_dynamic+1 WHERE id=f.id;
        ELSE
            UPDATE thundersnarf_domain SET requested=requested+1, last_requested=timestamp_1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1 WHERE id=d.id;
            UPDATE thundersnarf_extension SET requested=requested+1, last_requested=timestamp_1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1, last_url=url_7  WHERE id=e.id;
            UPDATE thundersnarf_ip SET requested=requested+1, last_requested=timestamp_1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1  WHERE id=i.id;
            UPDATE thundersnarf_domainip SET requested=requested+1, last_requested=timestamp_1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1  WHERE domain_id=d.id AND ip_id = i.id;
            UPDATE thundersnarf_data SET requested=requested+1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1  WHERE id_data=dt.id_data;
            UPDATE thundersnarf_file SET requested=requested+1, size=filesize_4, last_requested=timestamp_1, traffic_dynamic=traffic_dynamic+transfered_5, miss_dynamic=miss_dynamic+1 WHERE id=f.id;
        END IF;
    END IF;
    return true;
 end;$_$
    LANGUAGE plpgsql;


ALTER FUNCTION public.insertfile(integer, character varying, character varying, bigint, bigint, character varying, character varying, character varying, character varying, boolean, boolean, character varying) OWNER TO thundersnarf;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: thundersnarf_domain; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_domain (
    id integer NOT NULL,
    "domain" character varying(300) NOT NULL,
    createdate timestamp with time zone DEFAULT now() NOT NULL,
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL,
    last_requested integer DEFAULT 0 NOT NULL,
    requested bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.thundersnarf_domain OWNER TO thundersnarf;

--
-- Name: thunder_domain_id_seq; Type: SEQUENCE; Schema: public; Owner: thundersnarf
--

CREATE SEQUENCE thunder_domain_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.thunder_domain_id_seq OWNER TO thundersnarf;

--
-- Name: thunder_domain_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thundersnarf
--

ALTER SEQUENCE thunder_domain_id_seq OWNED BY thundersnarf_domain.id;


--
-- Name: thundersnarf_extension; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_extension (
    id integer NOT NULL,
    extension character(5),
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL,
    last_requested integer DEFAULT 0 NOT NULL,
    requested bigint DEFAULT 0 NOT NULL,
    last_url character varying(4000)
);


ALTER TABLE public.thundersnarf_extension OWNER TO thundersnarf;

--
-- Name: thunder_extension_id_seq; Type: SEQUENCE; Schema: public; Owner: thundersnarf
--

CREATE SEQUENCE thunder_extension_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.thunder_extension_id_seq OWNER TO thundersnarf;

--
-- Name: thunder_extension_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thundersnarf
--

ALTER SEQUENCE thunder_extension_id_seq OWNED BY thundersnarf_extension.id;


--
-- Name: thundersnarf_file; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_file (
    id integer NOT NULL,
    domain_id bigint NOT NULL,
    file character varying(300) NOT NULL,
    size bigint NOT NULL,
    requested integer DEFAULT 0 NOT NULL,
    extension character varying(5),
    last_requested integer DEFAULT 0 NOT NULL,
    downloaded integer NOT NULL,
    url character varying(4000),
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.thundersnarf_file OWNER TO thundersnarf;

--
-- Name: thunder_file_id_seq; Type: SEQUENCE; Schema: public; Owner: thundersnarf
--

CREATE SEQUENCE thunder_file_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.thunder_file_id_seq OWNER TO thundersnarf;

--
-- Name: thunder_file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thundersnarf
--

ALTER SEQUENCE thunder_file_id_seq OWNED BY thundersnarf_file.id;


--
-- Name: thundersnarf_ip; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_ip (
    id integer NOT NULL,
    ip character(15),
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL,
    last_requested integer DEFAULT 0 NOT NULL,
    requested bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.thundersnarf_ip OWNER TO thundersnarf;

--
-- Name: thunder_ip_id_seq; Type: SEQUENCE; Schema: public; Owner: thundersnarf
--

CREATE SEQUENCE thunder_ip_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.thunder_ip_id_seq OWNER TO thundersnarf;

--
-- Name: thunder_ip_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thundersnarf
--

ALTER SEQUENCE thunder_ip_id_seq OWNED BY thundersnarf_ip.id;


--
-- Name: thundersnarf_data; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_data (
    id_data integer NOT NULL,
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL,
    requested bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.thundersnarf_data OWNER TO thundersnarf;

--
-- Name: thundersnarf_domainip; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_domainip (
    domain_id bigint NOT NULL,
    ip_id bigint NOT NULL,
    cache_static bigint DEFAULT 0 NOT NULL,
    cache_dynamic bigint DEFAULT 0 NOT NULL,
    traffic_static bigint DEFAULT 0 NOT NULL,
    traffic_dynamic bigint DEFAULT 0 NOT NULL,
    hit_static bigint DEFAULT 0 NOT NULL,
    hit_dynamic bigint DEFAULT 0 NOT NULL,
    miss_static bigint DEFAULT 0 NOT NULL,
    miss_dynamic bigint DEFAULT 0 NOT NULL,
    last_requested integer DEFAULT 0 NOT NULL,
    requested bigint DEFAULT 0 NOT NULL
);


ALTER TABLE public.thundersnarf_domainip OWNER TO thundersnarf;

--
-- Name: thundersnarf_user; Type: TABLE; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE TABLE thundersnarf_user (
    id integer NOT NULL,
    username character varying(128) NOT NULL,
    "password" character varying(128) NOT NULL,
    email character varying(128) NOT NULL,
    profile text,
    last_acess integer,
    last_ip character varying(15)
);

ALTER TABLE public.thundersnarf_user OWNER TO thundersnarf;

--
-- Name: thundersnarf_user_id_seq; Type: SEQUENCE; Schema: public; Owner: thundersnarf
--

CREATE SEQUENCE thundersnarf_user_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.thundersnarf_user_id_seq OWNER TO thundersnarf;

--
-- Name: thundersnarf_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thundersnarf
--

ALTER SEQUENCE thundersnarf_user_id_seq OWNED BY thundersnarf_user.id;


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: thundersnarf
--

ALTER TABLE thundersnarf_user ALTER COLUMN id SET DEFAULT nextval('thundersnarf_user_id_seq'::regclass);


--
-- Name: thundersnarf_user_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_user
    ADD CONSTRAINT thundersnarf_user_pkey PRIMARY KEY (id);

--
-- Name: thundersnarf_user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: thundersnarf
--

--
-- Cadastro do usuario padrao:
-- USUSARIO: admin
-- SENHA: admin
--

SELECT pg_catalog.setval('thundersnarf_user_id_seq', 2, true);

INSERT INTO thundersnarf_user VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'modifiqueoemail@modifiqueoemail.com.br', 'Usuario cadastrado na instalacao', 1274126219, '127.0.0.1');
INSERT INTO thundersnarf_user VALUES (2, 'freebsdbrasil', '21232f297a57a5a743894a0e4a801fc3', 'consultoria@freebsdbrasil.com.br', 'FreeBSD Brasil Ltda');



--
-- Name: id; Type: DEFAULT; Schema: public; Owner: thundersnarf
--

ALTER TABLE thundersnarf_domain ALTER COLUMN id SET DEFAULT nextval('thunder_domain_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: thundersnarf
--

ALTER TABLE thundersnarf_extension ALTER COLUMN id SET DEFAULT nextval('thunder_extension_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: thundersnarf
--

ALTER TABLE thundersnarf_file ALTER COLUMN id SET DEFAULT nextval('thunder_file_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: thundersnarf
--

ALTER TABLE thundersnarf_ip ALTER COLUMN id SET DEFAULT nextval('thunder_ip_id_seq'::regclass);


--
-- Name: thunder_data_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_data
    ADD CONSTRAINT thunder_data_pkey PRIMARY KEY (id_data);


--
-- Name: thunder_domain_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_domain
    ADD CONSTRAINT thunder_domain_pkey PRIMARY KEY (id);


--
-- Name: thunder_domainip_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_domainip
    ADD CONSTRAINT thunder_domainip_pkey PRIMARY KEY (domain_id, ip_id);


--
-- Name: thunder_extension_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_extension
    ADD CONSTRAINT thunder_extension_pkey PRIMARY KEY (id);


--
-- Name: thunder_file_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_file
    ADD CONSTRAINT thunder_file_pkey PRIMARY KEY (id);


--
-- Name: thunder_ip_pkey; Type: CONSTRAINT; Schema: public; Owner: thundersnarf; Tablespace: 
--

ALTER TABLE ONLY thundersnarf_ip
    ADD CONSTRAINT thunder_ip_pkey PRIMARY KEY (id);


--
-- Name: domain_id; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX domain_id ON thundersnarf_domainip USING btree (domain_id);


--
-- Name: extension_index; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX extension_index ON thundersnarf_extension USING btree (extension);


--
-- Name: file_index; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX file_index ON thundersnarf_file USING btree (file);


--
-- Name: indice_domain; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE UNIQUE INDEX indice_domain ON thundersnarf_domain USING btree ("domain");


--
-- Name: indice_id_domain; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE UNIQUE INDEX indice_id_domain ON thundersnarf_domain USING btree (id);


--
-- Name: indice_id_file; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE UNIQUE INDEX indice_id_file ON thundersnarf_file USING btree (id);


--
-- Name: ip_id; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX ip_id ON thundersnarf_domainip USING btree (ip_id);


--
-- Name: ip_index; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX ip_index ON thundersnarf_ip USING btree (ip);


--
-- Name: url_index; Type: INDEX; Schema: public; Owner: thundersnarf; Tablespace: 
--

CREATE INDEX url_index ON thundersnarf_file USING btree (url);


--
-- Name: thunder_domainip_domain_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: thundersnarf
--

ALTER TABLE ONLY thundersnarf_domainip
    ADD CONSTRAINT thunder_domainip_domain_id_fkey FOREIGN KEY (domain_id) REFERENCES thundersnarf_domain(id) ON DELETE CASCADE;


--
-- Name: thunder_domainip_ip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: thundersnarf
--

ALTER TABLE ONLY thundersnarf_domainip
    ADD CONSTRAINT thunder_domainip_ip_id_fkey FOREIGN KEY (ip_id) REFERENCES thundersnarf_ip(id) ON DELETE CASCADE;


--
-- Name: thunder_file_domain_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: thundersnarf
--

ALTER TABLE ONLY thundersnarf_file
    ADD CONSTRAINT thunder_file_domain_id_fkey FOREIGN KEY (domain_id) REFERENCES thundersnarf_domain(id) ON DELETE CASCADE;


--
-- Name: public; Type: ACL; Schema: -; Owner: pgsql
--

--
-- PostgreSQL database dump complete
--

