--
-- PostgreSQL database dump
--

SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- Name: testdb; Type: DATABASE; Schema: -; Owner: postgres
--

CREATE DATABASE testdb WITH TEMPLATE = template0 ENCODING = 'UTF8';


ALTER DATABASE testdb OWNER TO postgres;

\connect testdb

SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;

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

COMMENT ON SCHEMA public IS 'Standard public schema';


SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: test1; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE test1 (
    id bigserial NOT NULL,
    some_text text NOT NULL
);


ALTER TABLE public.test1 OWNER TO postgres;

--
-- Name: TABLE test1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE test1 IS 'Test table with Rules';


--
-- Name: COLUMN test1.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN test1.id IS 'ID';


--
-- Name: test1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('test1', 'id'), 1, true);


--
-- Name: test_log1; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE test_log1 (
    qid bigint NOT NULL,
    when_happened timestamp without time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.test_log1 OWNER TO postgres;

--
-- Name: TABLE test_log1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE test_log1 IS 'Table were we log inserts to test1';


--
-- Data for Name: test1; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY test1 (id, some_text) FROM stdin;
\.


--
-- Data for Name: test_log1; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY test_log1 (qid, when_happened) FROM stdin;
\.


--
-- Name: test1_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY test1
    ADD CONSTRAINT test1_pkey PRIMARY KEY (id);


--
-- Name: test_log1_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY test_log1
    ADD CONSTRAINT test_log1_pkey PRIMARY KEY (qid);


--
-- Name: test1_on_insert; Type: RULE; Schema: public; Owner: postgres
--

CREATE RULE test1_on_insert AS ON INSERT TO test1 DO INSERT INTO test_log1 (qid) VALUES (new.id);


--
-- Name: RULE test1_on_insert ON test1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON RULE test1_on_insert ON test1 IS 'on insert update test_log1';


--
-- 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 postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- PostgreSQL database dump complete
--

