--
--


--
-- 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;



--
-- 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,
    logged_user integer
);


--
-- 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 48 (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,
    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 49 (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,
    edit_anon boolean DEFAULT true NOT NULL,
    create_account_anon boolean DEFAULT true NOT NULL,
    theme_css text,
    feedback_email text,
    mailing_list boolean DEFAULT false NOT NULL,
    is_template boolean DEFAULT false NOT NULL,
    search_box boolean DEFAULT true NOT NULL,
    view_anon boolean DEFAULT true NOT NULL,
    navigation boolean DEFAULT false NOT NULL,
    powered_by integer
);


--
-- 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 50 (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 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 14 (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 51 (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 15 (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 16 (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 52 (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 17 (OID 540816)
-- Name: users; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE users (
    id serial NOT NULL,
    hostid integer NOT NULL,
    name text NOT NULL,
    "password" text NOT NULL,
    email text,
    registration_date date DEFAULT ('now'::text)::date NOT NULL,
    can_edit boolean DEFAULT true NOT NULL,
    can_manage_users boolean DEFAULT false NOT NULL,
    can_manage_contacts boolean DEFAULT false NOT NULL,
    can_manage_site boolean DEFAULT false NOT NULL,
    can_edit_global_css boolean DEFAULT false NOT NULL,
    force_password_change boolean DEFAULT false NOT NULL,
    can_import_mail boolean DEFAULT false NOT NULL,
    email_notify boolean DEFAULT true NOT NULL
);


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

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


--
-- TOC entry 53 (OID 540816)
-- Name: users_id_seq; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 19 (OID 540832)
-- Name: usercookies; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE usercookies (
    userid integer NOT NULL,
    cookie text NOT NULL
);


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

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


--
-- TOC entry 21 (OID 540961)
-- Name: sitemenu; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE sitemenu (
    hostid integer NOT NULL,
    url text NOT NULL,
    label text NOT NULL,
    ordering integer NOT NULL
);


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

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


--
-- TOC entry 23 (OID 542605)
-- Name: contacts; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE contacts (
    id serial NOT NULL,
    hostid integer NOT NULL,
    name text NOT NULL,
    subject text NOT NULL
);


--
-- TOC entry 24 (OID 542605)
-- Name: contacts; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 54 (OID 542605)
-- Name: contacts_id_seq; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 25 (OID 542617)
-- Name: contact_emails; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE contact_emails (
    contactid integer NOT NULL,
    email text NOT NULL
);


--
-- TOC entry 26 (OID 542617)
-- Name: contact_emails; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 27 (OID 543499)
-- Name: themes; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE themes (
    theme_css text NOT NULL,
    name text NOT NULL,
    description text NOT NULL
);


--
-- TOC entry 28 (OID 543499)
-- Name: themes; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 29 (OID 543592)
-- Name: server_settings; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE server_settings (
    "version" integer NOT NULL,
    stats_page text,
    crash_email text
);


--
-- TOC entry 31 (OID 543592)
-- Name: server_settings; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 32 (OID 543754)
-- Name: page_emails; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE page_emails (
    hostid integer NOT NULL,
    url text NOT NULL,
    email text NOT NULL,
    entry_date date DEFAULT ('now'::text)::date NOT NULL,
    last_sent date DEFAULT ('now'::text)::date NOT NULL,
    pending text,
    opt_out text NOT NULL
);


--
-- TOC entry 33 (OID 543754)
-- Name: page_emails; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 34 (OID 543785)
-- Name: mailing_lists; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE mailing_lists (
    hostid integer NOT NULL,
    email text NOT NULL,
    entry_date date DEFAULT ('now'::text)::date NOT NULL,
    pending text,
    opt_out text NOT NULL,
    name text NOT NULL
);


--
-- TOC entry 35 (OID 543785)
-- Name: mailing_lists; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 36 (OID 544445)
-- Name: links; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE links (
    hostid integer NOT NULL,
    from_url text NOT NULL,
    to_url text NOT NULL,
    CONSTRAINT links_not_selfref_cn CHECK ((from_url <> to_url))
);


--
-- TOC entry 37 (OID 544445)
-- Name: links; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 38 (OID 547939)
-- Name: templates; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE templates (
    id serial NOT NULL,
    title_regexp text NOT NULL,
    url_regexp text NOT NULL,
    extension text NOT NULL,
    ordering integer NOT NULL
);


--
-- TOC entry 39 (OID 547939)
-- Name: templates; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 55 (OID 547939)
-- Name: templates_id_seq; Type: ACL; Schema: public; Owner: rich
--

REVOKE ALL ON TABLE templates_id_seq FROM PUBLIC;


--
-- TOC entry 40 (OID 551123)
-- Name: recently_visited; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE recently_visited (
    userid integer NOT NULL,
    hostid integer NOT NULL,
    url text NOT NULL,
    visit_time timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL
);


--
-- TOC entry 41 (OID 551123)
-- Name: recently_visited; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 42 (OID 551675)
-- Name: messages; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE messages (
    id serial NOT NULL,
    subject text NOT NULL,
    inet_message_id text NOT NULL,
    message_date timestamp with time zone NOT NULL,
    hostid integer NOT NULL
);


--
-- TOC entry 43 (OID 551675)
-- Name: messages; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 56 (OID 551675)
-- Name: messages_id_seq; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 44 (OID 551685)
-- Name: msg_references; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE msg_references (
    message_id integer NOT NULL,
    inet_message_id text NOT NULL,
    ordering integer NOT NULL
);


--
-- TOC entry 45 (OID 551685)
-- Name: msg_references; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 46 (OID 607075)
-- Name: powered_by; Type: TABLE; Schema: public; Owner: rich
--

CREATE TABLE powered_by (
    id serial NOT NULL,
    name text NOT NULL,
    url text NOT NULL
);


--
-- TOC entry 47 (OID 607075)
-- Name: powered_by; Type: ACL; Schema: public; Owner: rich
--

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


--
-- TOC entry 63 (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 64 (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 60 (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 65 (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 67 (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 70 (OID 540831)
-- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX users_name_uq ON users USING btree (hostid, name);


--
-- TOC entry 69 (OID 540946)
-- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id);


--
-- TOC entry 72 (OID 540970)
-- Name: sitemenu_ordering_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX sitemenu_ordering_uq ON sitemenu USING btree (hostid, ordering);


--
-- TOC entry 73 (OID 540971)
-- Name: sitemenu_url_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX sitemenu_url_uq ON sitemenu USING btree (hostid, url);


--
-- TOC entry 76 (OID 542626)
-- Name: contact_emails_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX contact_emails_uq ON contact_emails USING btree (contactid, email);


--
-- TOC entry 77 (OID 543505)
-- Name: themes_theme_css_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX themes_theme_css_uq ON themes USING btree (theme_css);


--
-- TOC entry 78 (OID 543763)
-- Name: page_emails_email_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX page_emails_email_uq ON page_emails USING btree (hostid, url, email);


--
-- TOC entry 79 (OID 543795)
-- Name: mailing_lists_email_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX mailing_lists_email_uq ON mailing_lists USING btree (hostid, email);


--
-- TOC entry 74 (OID 543880)
-- Name: contacts_name_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX contacts_name_uq ON contacts USING btree (hostid, name);


--
-- TOC entry 80 (OID 544454)
-- Name: links_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX links_uq ON links USING btree (hostid, from_url, to_url);


--
-- TOC entry 81 (OID 547951)
-- Name: templates_ext_ord_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX templates_ext_ord_uq ON templates USING btree (extension, ordering);


--
-- TOC entry 83 (OID 547952)
-- Name: templates_title_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX templates_title_uq ON templates USING btree (title_regexp);


--
-- TOC entry 84 (OID 547953)
-- Name: templates_url_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX templates_url_uq ON templates USING btree (url_regexp);


--
-- TOC entry 85 (OID 551151)
-- Name: recently_visited_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX recently_visited_uq ON recently_visited USING btree (userid, hostid, url);


--
-- TOC entry 86 (OID 552155)
-- Name: messages_inet_message_id_uq; Type: INDEX; Schema: public; Owner: rich
--

CREATE UNIQUE INDEX messages_inet_message_id_uq ON messages USING btree (hostid, inet_message_id);


--
-- TOC entry 59 (OID 552684)
-- Name: pages_url_ix; Type: INDEX; Schema: public; Owner: rich
--

CREATE INDEX pages_url_ix ON pages USING btree (url);


--
-- TOC entry 58 (OID 552685)
-- Name: pages_redirect_ix; Type: INDEX; Schema: public; Owner: rich
--

CREATE INDEX pages_redirect_ix ON pages USING btree (redirect);


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

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


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

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


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

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


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

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


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

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


--
-- TOC entry 71 (OID 540825)
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- TOC entry 75 (OID 542611)
-- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY contacts
    ADD CONSTRAINT contacts_pkey PRIMARY KEY (id);


--
-- TOC entry 82 (OID 547945)
-- Name: templates_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY templates
    ADD CONSTRAINT templates_pkey PRIMARY KEY (id);


--
-- TOC entry 87 (OID 551681)
-- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY messages
    ADD CONSTRAINT messages_pkey PRIMARY KEY (id);


--
-- TOC entry 88 (OID 607081)
-- Name: powered_by_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY powered_by
    ADD CONSTRAINT powered_by_pkey PRIMARY KEY (id);


--
-- TOC entry 93 (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 97 (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 94 (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 89 (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 98 (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 99 (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 90 (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;


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

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


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

ALTER TABLE ONLY usercookies
    ADD CONSTRAINT "$1" FOREIGN KEY (userid) REFERENCES users(id);


--
-- TOC entry 91 (OID 540942)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY pages
    ADD CONSTRAINT "$2" FOREIGN KEY (logged_user) REFERENCES users(id);


--
-- TOC entry 92 (OID 540947)
-- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY pages
    ADD CONSTRAINT pages_user_cn FOREIGN KEY (hostid, logged_user) REFERENCES users(hostid, id);


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

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


--
-- TOC entry 103 (OID 540972)
-- Name: sitemenu_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

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


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

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


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

ALTER TABLE ONLY contact_emails
    ADD CONSTRAINT "$1" FOREIGN KEY (contactid) REFERENCES contacts(id);


--
-- TOC entry 95 (OID 543506)
-- Name: hosts_theme_css_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY hosts
    ADD CONSTRAINT hosts_theme_css_cn FOREIGN KEY (theme_css) REFERENCES themes(theme_css);


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

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


--
-- TOC entry 107 (OID 543764)
-- Name: page_emails_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

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


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

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


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

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


--
-- TOC entry 110 (OID 544455)
-- Name: links_from_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY links
    ADD CONSTRAINT links_from_cn FOREIGN KEY (hostid, from_url) REFERENCES pages(hostid, url) DEFERRABLE;


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

ALTER TABLE ONLY recently_visited
    ADD CONSTRAINT "$1" FOREIGN KEY (userid) REFERENCES users(id);


--
-- TOC entry 112 (OID 551133)
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

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


--
-- TOC entry 113 (OID 551137)
-- Name: recently_visited_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

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


--
-- TOC entry 114 (OID 551141)
-- Name: recently_visited_userid_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY recently_visited
    ADD CONSTRAINT recently_visited_userid_cn FOREIGN KEY (hostid, userid) REFERENCES users(hostid, id);


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

ALTER TABLE ONLY msg_references
    ADD CONSTRAINT "$1" FOREIGN KEY (message_id) REFERENCES messages(id);


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

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


--
-- TOC entry 96 (OID 607083)
-- Name: hosts_powered_by_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
--

ALTER TABLE ONLY hosts
    ADD CONSTRAINT hosts_powered_by_cn FOREIGN KEY (powered_by) REFERENCES powered_by(id);


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

COMMENT ON SCHEMA public IS 'Standard public namespace';


--
-- TOC entry 30 (OID 543592)
-- Name: TABLE server_settings; Type: COMMENT; Schema: public; Owner: rich
--

COMMENT ON TABLE server_settings IS 'This table contains global settings for the server.  There should be only one row in this table.  If you modify any setting, you must restart the webserver for the change to take effect.  The "version" field is intended to be some sort of database version, but is currently unused.';


--
--



--
-- Data for TOC entry 3 (OID 547939)
-- Name: templates; Type: TABLE DATA; Schema: public; Owner: rich
--

COPY templates (id, title_regexp, url_regexp, extension, ordering) FROM stdin;
1	^(199[0-9]|20[0-9][0-9])/(0[1-9]|1[0-2])/(0[1-9]|1[0-9]|2[0-9]|3[01])$	^(199[0-9]|20[0-9][0-9])/(0[1-9]|1[0-2])/(0[1-9]|1[0-9]|2[0-9]|3[01])$	calendar	10
3	^(199[0-9]|20[0-9][0-9])/(0[1-9]|1[0-2])$	^(199[0-9]|20[0-9][0-9])/(0[1-9]|1[0-2])$	calendar	20
4	^(199[0-9]|20[0-9][0-9])$	^(199[0-9]|20[0-9][0-9])$	calendar	30
\.


--
-- TOC entry 2 (OID 547937)
-- Name: templates_id_seq; Type: SEQUENCE SET; Schema: public; Owner: rich
--

SELECT pg_catalog.setval('templates_id_seq', 4, true);


--
--



--
-- Data for TOC entry 2 (OID 543499)
-- Name: themes; Type: TABLE DATA; Schema: public; Owner: rich
--

COPY themes (theme_css, name, description) FROM stdin;
/_css/easyweb.css	Merjis Easy Web Marketing	This is the easy web marketing stylesheet developed by Merjis Ltd.  Please see http://www.merjis.com/
/_css/basic.css	Basic styles only	Only the most essential styles.  This is a good starting point if you want to completely restyle pages using site-specific CSS.
\.


