--
-- PostgreSQL database dump
--

SET client_encoding = 'UNICODE';
SET check_function_bodies = false;

SET SESSION AUTHORIZATION 'postgres';

--
-- TOC entry 4 (OID 2200)
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


SET SESSION AUTHORIZATION 'rich';

SET search_path = public, pg_catalog;

--
-- TOC entry 5 (OID 536004)
-- Name: pages; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE pages (
    id serial NOT NULL,
    url text,
    url_deleted text,
    title text NOT NULL,
    description text NOT NULL,
    creation_date timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
    last_modified_date timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL,
    hostid integer NOT NULL,
    logged_ip text,
    redirect text,
    css text
);


--
-- TOC entry 6 (OID 536004)
-- Name: pages; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE pages FROM PUBLIC;
GRANT ALL ON TABLE pages TO "www-data";


--
-- TOC entry 19 (OID 536004)
-- Name: pages_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE pages_id_seq FROM PUBLIC;
GRANT ALL ON TABLE pages_id_seq TO "www-data";


--
-- TOC entry 7 (OID 536021)
-- Name: contents; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE contents (
    id serial NOT NULL,
    pageid integer NOT NULL,
    ordering integer NOT NULL,
    sectionname text NOT NULL,
    content text NOT NULL,
    divname text
);


--
-- TOC entry 8 (OID 536021)
-- Name: contents; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE contents FROM PUBLIC;
GRANT ALL ON TABLE contents TO "www-data";


--
-- TOC entry 20 (OID 536021)
-- Name: contents_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE contents_id_seq FROM PUBLIC;
GRANT ALL ON TABLE contents_id_seq TO "www-data";


--
-- TOC entry 9 (OID 536371)
-- Name: hosts; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE hosts (
    id serial NOT NULL,
    canonical_hostname text NOT NULL,
    css text
);


--
-- TOC entry 10 (OID 536371)
-- Name: hosts; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE hosts FROM PUBLIC;
GRANT ALL ON TABLE hosts TO "www-data";


--
-- TOC entry 21 (OID 536371)
-- Name: hosts_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE hosts_id_seq FROM PUBLIC;
GRANT ALL ON TABLE hosts_id_seq TO "www-data";


--
-- TOC entry 11 (OID 536379)
-- Name: hostnames; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE hostnames (
    hostid integer NOT NULL,
    name text NOT NULL
);


--
-- TOC entry 12 (OID 536379)
-- Name: hostnames; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE hostnames FROM PUBLIC;
GRANT ALL ON TABLE hostnames TO "www-data";


--
-- TOC entry 13 (OID 536915)
-- Name: email_notify; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE email_notify (
    hostid integer NOT NULL,
    email text NOT NULL,
    name text
);


--
-- TOC entry 14 (OID 536915)
-- Name: email_notify; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE email_notify FROM PUBLIC;
GRANT ALL ON TABLE email_notify TO "www-data";


--
-- TOC entry 15 (OID 537151)
-- Name: images; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE images (
    id serial NOT NULL,
    hostid integer NOT NULL,
    name text,
    name_deleted text,
    image bytea NOT NULL,
    width integer NOT NULL,
    height integer NOT NULL,
    alt text NOT NULL,
    title text,
    longdesc text,
    "class" text,
    mime_type text NOT NULL,
    thumbnail bytea,
    tn_width integer,
    tn_height integer,
    tn_mime_type text,
    upload_date timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL
);


--
-- TOC entry 16 (OID 537151)
-- Name: images; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE images FROM PUBLIC;
GRANT ALL ON TABLE images TO "www-data";


--
-- TOC entry 22 (OID 537151)
-- Name: images_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE images_id_seq FROM PUBLIC;
GRANT ALL ON TABLE images_id_seq TO "www-data";


--
-- TOC entry 17 (OID 537166)
-- Name: files; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE files (
    id serial NOT NULL,
    hostid integer NOT NULL,
    name text,
    name_deleted text,
    content bytea NOT NULL,
    title text,
    mime_type text NOT NULL,
    upload_date timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL
);


--
-- TOC entry 18 (OID 537166)
-- Name: files; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE files FROM PUBLIC;
GRANT ALL ON TABLE files TO "www-data";


--
-- TOC entry 23 (OID 537166)
-- Name: files_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE files_id_seq FROM PUBLIC;
GRANT ALL ON TABLE files_id_seq TO "www-data";


--
-- TOC entry 28 (OID 536388)
-- Name: hostnames_hostid_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX hostnames_hostid_name_uq ON hostnames USING btree (hostid, name);


--
-- TOC entry 29 (OID 536389)
-- Name: hostnams_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX hostnams_name_uq ON hostnames USING btree (name);


--
-- TOC entry 25 (OID 536419)
-- Name: pages_url_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX pages_url_uq ON pages USING btree (hostid, url);


--
-- TOC entry 30 (OID 536924)
-- Name: email_notify_email_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX email_notify_email_uq ON email_notify USING btree (hostid, email);


--
-- TOC entry 31 (OID 540251)
-- Name: images_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX images_name_uq ON images USING btree (hostid, name);


--
-- TOC entry 33 (OID 540252)
-- Name: files_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX files_name_uq ON files USING btree (hostid, name);


--
-- TOC entry 24 (OID 536012)
-- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY pages
    ADD CONSTRAINT pages_pkey PRIMARY KEY (id);


--
-- TOC entry 26 (OID 536027)
-- Name: contents_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY contents
    ADD CONSTRAINT contents_pkey PRIMARY KEY (id);


--
-- TOC entry 27 (OID 536377)
-- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY hosts
    ADD CONSTRAINT hosts_pkey PRIMARY KEY (id);


--
-- TOC entry 32 (OID 537158)
-- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY images
    ADD CONSTRAINT images_pkey PRIMARY KEY (id);


--
-- TOC entry 34 (OID 537173)
-- Name: files_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY files
    ADD CONSTRAINT files_pkey PRIMARY KEY (id);


--
-- TOC entry 37 (OID 536029)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY contents
    ADD CONSTRAINT "$1" FOREIGN KEY (pageid) REFERENCES pages(id);


--
-- TOC entry 39 (OID 536384)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY hostnames
    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);


--
-- TOC entry 38 (OID 536394)
-- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY hosts
    ADD CONSTRAINT hosts_hostname_cn FOREIGN KEY (id, canonical_hostname) REFERENCES hostnames(hostid, name) DEFERRABLE;


--
-- TOC entry 35 (OID 536404)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY pages
    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);


--
-- TOC entry 40 (OID 536920)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY email_notify
    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);


--
-- TOC entry 41 (OID 537160)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY images
    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);


--
-- TOC entry 42 (OID 537175)
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY files
    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);


--
-- TOC entry 36 (OID 539155)
-- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY pages
    ADD CONSTRAINT pages_redirect_cn FOREIGN KEY (hostid, redirect) REFERENCES pages(hostid, url) DEFERRABLE;


SET SESSION AUTHORIZATION 'postgres';

--
-- TOC entry 3 (OID 2200)
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'Standard public namespace';


