--
--



--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';



--
-- Name: add_phone(character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION add_phone(character varying, integer) RETURNS integer
    LANGUAGE sql
    AS $_$
	select setval ('phones_id_seq', (select case when max(id) is null then 1 else max(id) end from phones));
	insert into phones (id,phone,pers_id)
		values (nextval('phones_id_seq'),$1,$2);
	select max(id) from phones
$_$;


ALTER FUNCTION public.add_phone(character varying, integer) OWNER TO postgres;

--
-- Name: create_doc(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION create_doc() RETURNS integer
    LANGUAGE sql
    AS $$
	select setval ('documents_id_seq', (select case when max(id) is null then 1 else max(id) end from documents));
	insert into documents (id,title,abstract) 
		values ((select case when max(id) is null then 1 else nextval('documents_id_seq') end from documents),'','');
	select max(id) from documents
$$;


ALTER FUNCTION public.create_doc() OWNER TO postgres;

--
-- Name: create_o(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION create_o() RETURNS integer
    LANGUAGE sql
    AS $$
	select setval ('institutes_id_seq', (select case when max(id) is null then 1 else max(id) end from institutes));
	insert into institutes (id,name) 
		values ((select case when max(id) is null then 1 else nextval('institutes_id_seq') end from institutes),'');
	select max(id) from institutes
$$;


ALTER FUNCTION public.create_o() OWNER TO postgres;

--
-- Name: create_organizational_unit(); Type: FUNCTION; Schema: public; Owner: root
--

CREATE FUNCTION create_organizational_unit() RETURNS integer
    LANGUAGE sql
    AS $$
	select setval ('organizational_unit_id_seq', (select case when max(id) is null then 1 else max(id) end from organizational_unit));
	insert into organizational_unit (id,ou,description)
		values ((select case when max(id) is null then 1 else nextval('organizational_unit_id_seq') end from organizational_unit),'','');
	select max(id) from organizational_unit
$$;


ALTER FUNCTION public.create_organizational_unit() OWNER TO root;

--
-- Name: create_person(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION create_person() RETURNS integer
    LANGUAGE sql
    AS $$
	select setval ('persons_id_seq', (select case when max(id) is null then 1 else max(id) end from persons));
	insert into persons (id,name,surname) 
		values ((select case when max(id) is null then 1 else nextval('persons_id_seq') end from persons),'','');
	select max(id) from persons
$$;


ALTER FUNCTION public.create_person() OWNER TO postgres;

--
-- Name: create_referral(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION create_referral() RETURNS integer
    LANGUAGE sql
    AS $$
	select setval ('referrals_id_seq', (select case when max(id) is null then 1 else max(id) end from referrals));
	insert into referrals (id,name,url) 
		values ((select case when max(id) is null then 1 else nextval('referrals_id_seq') end from referrals),'','');
	select max(id) from referrals
$$;


ALTER FUNCTION public.create_referral() OWNER TO postgres;

--
-- Name: update_person_cn(character varying, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION update_person_cn(character varying, integer) RETURNS integer
    LANGUAGE sql
    AS $_$
	update persons set name = (
		select case 
			when position(' ' in $1) = 0 then $1 
			else substr($1, 1, position(' ' in $1) - 1)
		end
	),surname = (
		select case 
			when position(' ' in $1) = 0 then ''
			else substr($1, position(' ' in $1) + 1) 
		end
	) where id = $2;
	select $2 as return
$_$;


ALTER FUNCTION public.update_person_cn(character varying, integer) OWNER TO postgres;



--
-- Name: authors_docs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE authors_docs (
    pers_id integer NOT NULL,
    doc_id integer NOT NULL
);


ALTER TABLE authors_docs OWNER TO postgres;

--
-- Name: certs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE certs (
    id integer NOT NULL,
    cert bytea NOT NULL,
    pers_id integer NOT NULL
);


ALTER TABLE certs OWNER TO postgres;

--
-- Name: documents; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE documents (
    id integer NOT NULL,
    title character varying(255) NOT NULL,
    abstract character varying(255)
);


ALTER TABLE documents OWNER TO postgres;

--
-- Name: documents_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE documents_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE documents_id_seq OWNER TO postgres;

--
-- Name: documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE documents_id_seq OWNED BY documents.id;


--
-- Name: institutes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE institutes (
    id integer NOT NULL,
    name character varying(255)
);


ALTER TABLE institutes OWNER TO postgres;

--
-- Name: institutes_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE institutes_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE institutes_id_seq OWNER TO postgres;

--
-- Name: institutes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE institutes_id_seq OWNED BY institutes.id;


--
-- Name: ldap_attr_mappings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE ldap_attr_mappings (
    id integer NOT NULL,
    oc_map_id integer NOT NULL,
    name character varying(255) NOT NULL,
    sel_expr character varying(255) NOT NULL,
    sel_expr_u character varying(255),
    from_tbls character varying(255) NOT NULL,
    join_where character varying(255),
    add_proc character varying(255),
    delete_proc character varying(255),
    param_order integer NOT NULL,
    expect_return integer NOT NULL
);


ALTER TABLE ldap_attr_mappings OWNER TO postgres;

--
-- Name: ldap_attr_mappings_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE ldap_attr_mappings_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ldap_attr_mappings_id_seq OWNER TO postgres;

--
-- Name: ldap_attr_mappings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE ldap_attr_mappings_id_seq OWNED BY ldap_attr_mappings.id;


--
-- Name: ldap_entries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE ldap_entries (
    id integer NOT NULL,
    dn character varying(255) NOT NULL,
    oc_map_id integer NOT NULL,
    parent integer NOT NULL,
    keyval integer NOT NULL
);


ALTER TABLE ldap_entries OWNER TO postgres;

--
-- Name: ldap_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE ldap_entries_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ldap_entries_id_seq OWNER TO postgres;

--
-- Name: ldap_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE ldap_entries_id_seq OWNED BY ldap_entries.id;


--
-- Name: ldap_entry_objclasses; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE ldap_entry_objclasses (
    entry_id integer NOT NULL,
    oc_name character varying(64)
);


ALTER TABLE ldap_entry_objclasses OWNER TO postgres;

--
-- Name: ldap_oc_mappings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE ldap_oc_mappings (
    id integer NOT NULL,
    name character varying(64) NOT NULL,
    keytbl character varying(64) NOT NULL,
    keycol character varying(64) NOT NULL,
    create_proc character varying(255),
    delete_proc character varying(255),
    expect_return integer NOT NULL
);


ALTER TABLE ldap_oc_mappings OWNER TO postgres;

--
-- Name: ldap_oc_mappings_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE ldap_oc_mappings_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE ldap_oc_mappings_id_seq OWNER TO postgres;

--
-- Name: ldap_oc_mappings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE ldap_oc_mappings_id_seq OWNED BY ldap_oc_mappings.id;


--
-- Name: organizational_unit; Type: TABLE; Schema: public; Owner: root
--

CREATE TABLE organizational_unit (
    id integer NOT NULL,
    ou character varying(255),
    description character varying(255)
);


ALTER TABLE organizational_unit OWNER TO root;

--
-- Name: organizational_unit_id_seq; Type: SEQUENCE; Schema: public; Owner: root
--

CREATE SEQUENCE organizational_unit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE organizational_unit_id_seq OWNER TO root;

--
-- Name: organizational_unit_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: root
--

ALTER SEQUENCE organizational_unit_id_seq OWNED BY organizational_unit.id;


--
-- Name: persons; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE persons (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    surname character varying(255) NOT NULL,
    password character varying(64)
);


ALTER TABLE persons OWNER TO postgres;

--
-- Name: persons_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE persons_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE persons_id_seq OWNER TO postgres;

--
-- Name: persons_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE persons_id_seq OWNED BY persons.id;


--
-- Name: phones; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE phones (
    id integer NOT NULL,
    phone character varying(255) NOT NULL,
    pers_id integer NOT NULL
);


ALTER TABLE phones OWNER TO postgres;

--
-- Name: phones_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE phones_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE phones_id_seq OWNER TO postgres;

--
-- Name: phones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE phones_id_seq OWNED BY phones.id;


--
-- Name: referrals; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE referrals (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    url character varying(255) NOT NULL
);


ALTER TABLE referrals OWNER TO postgres;

--
-- Name: referrals_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE referrals_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE referrals_id_seq OWNER TO postgres;

--
-- Name: referrals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE referrals_id_seq OWNED BY referrals.id;


--
-- Name: documents id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY documents ALTER COLUMN id SET DEFAULT nextval('documents_id_seq'::regclass);


--
-- Name: institutes id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY institutes ALTER COLUMN id SET DEFAULT nextval('institutes_id_seq'::regclass);


--
-- Name: ldap_attr_mappings id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_attr_mappings ALTER COLUMN id SET DEFAULT nextval('ldap_attr_mappings_id_seq'::regclass);


--
-- Name: ldap_entries id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entries ALTER COLUMN id SET DEFAULT nextval('ldap_entries_id_seq'::regclass);


--
-- Name: ldap_oc_mappings id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_oc_mappings ALTER COLUMN id SET DEFAULT nextval('ldap_oc_mappings_id_seq'::regclass);


--
-- Name: organizational_unit id; Type: DEFAULT; Schema: public; Owner: root
--

ALTER TABLE ONLY organizational_unit ALTER COLUMN id SET DEFAULT nextval('organizational_unit_id_seq'::regclass);


--
-- Name: persons id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY persons ALTER COLUMN id SET DEFAULT nextval('persons_id_seq'::regclass);


--
-- Name: phones id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY phones ALTER COLUMN id SET DEFAULT nextval('phones_id_seq'::regclass);


--
-- Name: referrals id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY referrals ALTER COLUMN id SET DEFAULT nextval('referrals_id_seq'::regclass);


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

COPY authors_docs (pers_id, doc_id) FROM stdin;
1	1
1	2
2	1
\.


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

COPY certs (id, cert, pers_id) FROM stdin;
1	\\x3082036b308202d4a003020102020102300d06092a864886f70d01010405003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311f301d060355040a13164f70656e4c444150204578616d706c652c204c74642e311330110603550403130a4578616d706c65204341311d301b06092a864886f70d010901160e6361406578616d706c652e636f6d301e170d3033313031373136333331395a170d3034313031363136333331395a307e310b3009060355040613025553311330110603550408130a43616c69666f726e6961311f301d060355040a13164f70656e4c444150204578616d706c652c204c74642e311830160603550403130f557273756c612048616d7073746572311f301d06092a864886f70d01090116107568616d406578616d706c652e636f6d30819f300d06092a864886f70d010101050003818d0030818902818100eec60a7910b57d2e687158ca55eea738d36f10413dfecf31435e1aeeb9713b8e2da7dd2dde6bc6cec03b4987eaa7b037b9eb50e11c71e58088cc282883122cd8329c6f24f6045e6be9d21b9190c8292998267a5f7905292de936262747ab4b76a88a63872c41629a69d32e894d44c896a8d06fab0a1bc7de343c6c1458478f290203010001a381ff3081fc30090603551d1304023000302c06096086480186f842010d041f161d4f70656e53534c2047656e657261746564204365727469666963617465301d0603551d0e04160414a323de136c19ae0c479450e882dfb10ad147f45e3081a10603551d2304819930819680144b6f211a3624d290f943b053472d7de1c0e69823a17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311f301d060355040a13164f70656e4c444150204578616d706c652c204c74642e311330110603550403130a4578616d706c65204341311d301b06092a864886f70d010901160e6361406578616d706c652e636f6d820100300d06092a864886f70d010104050003818100881470045bdce95660d6e6af59e6a844aec4b9f5eaea88d4eb7a5a47080afa64750f81a3e47d00fd39c69a17a1c66d29d36f06edc537107f8c592239c2d4da55fb3f1d488e7b2387ad2a551cbd1ceb070ae9e020a9467275cb28798abb4cbfff98ddb3f1e7689b067072392511bb08125b5bec2bc207b7b6b275c47248f29acd	3
\.


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

COPY documents (id, title, abstract) FROM stdin;
1	book1	abstract1
2	book2	abstract2
\.


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

COPY institutes (id, name) FROM stdin;
1	Example
\.




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

COPY ldap_entries (id, dn, oc_map_id, parent, keyval) FROM stdin;
2	cn=Mitya Kovalev,dc=directory,dc=pbx,dc=local	1	1	1
3	cn=Torvlobnor Puzdoy,dc=directory,dc=pbx,dc=local	1	1	2
4	cn=Akakiy Zinberstein,dc=directory,dc=pbx,dc=local	1	1	3
5	documentTitle=book1,dc=directory,dc=pbx,dc=local	2	1	1
6	documentTitle=book2,dc=directory,dc=pbx,dc=local	2	1	2
7	ou=Referral,dc=directory,dc=pbx,dc=local	4	1	1
1	dc=directory,dc=pbx,dc=local	3	0	1
8	ou=users,dc=directory,dc=pbx,dc=local	5	1	1
\.


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

COPY ldap_entry_objclasses (entry_id, oc_name) FROM stdin;
1	dcObject
4	pkiUser
7	extensibleObject
\.


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

COPY ldap_oc_mappings (id, name, keytbl, keycol, create_proc, delete_proc, expect_return) FROM stdin;
1	inetOrgPerson	persons	id	SELECT create_person()	DELETE FROM persons WHERE id=?	0
2	document	documents	id	SELECT create_doc()	DELETE FROM documents WHERE id=?	0
3	organization	institutes	id	SELECT create_o()	DELETE FROM institutes WHERE id=?	0
4	referral	referrals	id	SELECT create_referral()	DELETE FROM referrals WHERE id=?	0
5	organizationalUnit	organizational_unit	id	SELECT create_organizational_unit()	DELETE FROM organizational_unit WHERE id=?	0
\.


--
-- Data for Name: organizational_unit; Type: TABLE DATA; Schema: public; Owner: root
--

COPY organizational_unit (id, ou, description) FROM stdin;
1		
\.


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

COPY persons (id, name, surname, password) FROM stdin;
2	Mitya	Kovalev	mit123
3	Torvlobnor	Puzdoy	tor123
1	Mitya	Kovalev	mit
\.


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

COPY phones (id, phone, pers_id) FROM stdin;
1	332-2334	1
2	222-3234	1
3	545-4563	2
\.


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

COPY referrals (id, name, url) FROM stdin;
1	Referral	ldap://localhost:9012/
\.


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

SELECT pg_catalog.setval('documents_id_seq', 1, false);


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

SELECT pg_catalog.setval('institutes_id_seq', 1, false);


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

SELECT pg_catalog.setval('ldap_attr_mappings_id_seq', 20, true);


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

SELECT pg_catalog.setval('ldap_entries_id_seq', 1, false);


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

SELECT pg_catalog.setval('ldap_oc_mappings_id_seq', 5, true);


--
-- Name: organizational_unit_id_seq; Type: SEQUENCE SET; Schema: public; Owner: root
--

SELECT pg_catalog.setval('organizational_unit_id_seq', 1, true);


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

SELECT pg_catalog.setval('persons_id_seq', 1, false);


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

SELECT pg_catalog.setval('phones_id_seq', 1, false);


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

SELECT pg_catalog.setval('referrals_id_seq', 1, false);


--
-- Name: authors_docs authors_docs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY authors_docs
    ADD CONSTRAINT authors_docs_pkey PRIMARY KEY (pers_id, doc_id);


--
-- Name: certs certs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY certs
    ADD CONSTRAINT certs_pkey PRIMARY KEY (id);


--
-- Name: documents documents_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY documents
    ADD CONSTRAINT documents_pkey PRIMARY KEY (id);


--
-- Name: institutes institutes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY institutes
    ADD CONSTRAINT institutes_pkey PRIMARY KEY (id);


--
-- Name: ldap_attr_mappings ldap_attr_mappings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_attr_mappings
    ADD CONSTRAINT ldap_attr_mappings_pkey PRIMARY KEY (id);


--
-- Name: ldap_entries ldap_entries_dn_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entries
    ADD CONSTRAINT ldap_entries_dn_key UNIQUE (dn);


--
-- Name: ldap_entries ldap_entries_oc_map_id_keyval_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entries
    ADD CONSTRAINT ldap_entries_oc_map_id_keyval_key UNIQUE (oc_map_id, keyval);


--
-- Name: ldap_entries ldap_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entries
    ADD CONSTRAINT ldap_entries_pkey PRIMARY KEY (id);


--
-- Name: ldap_oc_mappings ldap_oc_mappings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_oc_mappings
    ADD CONSTRAINT ldap_oc_mappings_pkey PRIMARY KEY (id);


--
-- Name: persons persons_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY persons
    ADD CONSTRAINT persons_pkey PRIMARY KEY (id);


--
-- Name: phones phones_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY phones
    ADD CONSTRAINT phones_pkey PRIMARY KEY (id);


--
-- Name: referrals referrals_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY referrals
    ADD CONSTRAINT referrals_pkey PRIMARY KEY (id);


--
-- Name: ldap_attr_mappings ldap_attr_mappings_oc_map_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_attr_mappings
    ADD CONSTRAINT ldap_attr_mappings_oc_map_id_fkey FOREIGN KEY (oc_map_id) REFERENCES ldap_oc_mappings(id);


--
-- Name: ldap_entries ldap_entries_oc_map_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entries
    ADD CONSTRAINT ldap_entries_oc_map_id_fkey FOREIGN KEY (oc_map_id) REFERENCES ldap_oc_mappings(id);


--
-- Name: ldap_entry_objclasses ldap_entry_objclasses_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY ldap_entry_objclasses
    ADD CONSTRAINT ldap_entry_objclasses_entry_id_fkey FOREIGN KEY (entry_id) REFERENCES ldap_entries(id);


--
-- Name: authors_docs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE authors_docs TO ldap;


--
-- Name: certs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE certs TO ldap;


--
-- Name: documents; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE documents TO ldap;


--
-- Name: documents_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE documents_id_seq TO ldap;


--
-- Name: institutes; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE institutes TO ldap;


--
-- Name: institutes_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE institutes_id_seq TO ldap;


--
-- Name: ldap_attr_mappings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE ldap_attr_mappings TO ldap;


--
-- Name: ldap_attr_mappings_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE ldap_attr_mappings_id_seq TO ldap;


--
-- Name: ldap_entries; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE ldap_entries TO ldap;


--
-- Name: ldap_entries_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE ldap_entries_id_seq TO ldap;


--
-- Name: ldap_entry_objclasses; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE ldap_entry_objclasses TO ldap;


--
-- Name: ldap_oc_mappings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE ldap_oc_mappings TO ldap;


--
-- Name: ldap_oc_mappings_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE ldap_oc_mappings_id_seq TO ldap;


--
-- Name: organizational_unit; Type: ACL; Schema: public; Owner: root
--

GRANT ALL ON TABLE organizational_unit TO ldap;


--
-- Name: organizational_unit_id_seq; Type: ACL; Schema: public; Owner: root
--

GRANT ALL ON SEQUENCE organizational_unit_id_seq TO ldap;


--
-- Name: persons; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE persons TO ldap;


--
-- Name: persons_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE persons_id_seq TO ldap;


--
-- Name: phones; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE phones TO ldap;


--
-- Name: phones_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE phones_id_seq TO ldap;


--
-- Name: referrals; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE referrals TO ldap;


--
-- Name: referrals_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE referrals_id_seq TO ldap;


--
--

