1drop table ldap_oc_mappings;
2drop sequence ldap_oc_mappings_id_seq;
3create table ldap_oc_mappings
4 (
5	id serial not null primary key,
6	name varchar(64) not null,
7	keytbl varchar(64) not null,
8	keycol varchar(64) not null,
9	create_proc varchar(255),
10	delete_proc varchar(255),
11	expect_return int not null
12);
13
14drop table ldap_attr_mappings;
15drop sequence ldap_attr_mappings_id_seq;
16create table ldap_attr_mappings
17 (
18	id serial not null primary key,
19	oc_map_id integer not null references ldap_oc_mappings(id),
20	name varchar(255) not null,
21	sel_expr varchar(255) not null,
22	sel_expr_u varchar(255),
23	from_tbls varchar(255) not null,
24	join_where varchar(255),
25	add_proc varchar(255),
26	delete_proc varchar(255),
27	param_order int not null,
28	expect_return int not null
29);
30
31drop table ldap_entries;
32drop sequence ldap_entries_id_seq;
33create table ldap_entries
34 (
35	id serial not null primary key,
36	dn varchar(255) not null,
37	oc_map_id integer not null references ldap_oc_mappings(id),
38	parent int NOT NULL,
39	keyval int NOT NULL,
40	UNIQUE ( oc_map_id, keyval ),
41	UNIQUE ( dn )
42);
43
44drop table ldap_entry_objclasses;
45create table ldap_entry_objclasses
46 (
47	entry_id integer not null references ldap_entries(id),
48	oc_name varchar(64)
49 );
50
51