1CREATE TABLE users (
2	userid                   number(20)                                NOT NULL,
3	alias                    nvarchar2(100)  DEFAULT ''                ,
4	name                     nvarchar2(100)  DEFAULT ''                ,
5	surname                  nvarchar2(100)  DEFAULT ''                ,
6	passwd                   nvarchar2(32)   DEFAULT ''                ,
7	url                      nvarchar2(255)  DEFAULT ''                ,
8	autologin                number(10)      DEFAULT '0'               NOT NULL,
9	autologout               nvarchar2(32)   DEFAULT '15m'             ,
10	lang                     nvarchar2(5)    DEFAULT 'en_GB'           ,
11	refresh                  nvarchar2(32)   DEFAULT '30s'             ,
12	type                     number(10)      DEFAULT '1'               NOT NULL,
13	theme                    nvarchar2(128)  DEFAULT 'default'         ,
14	attempt_failed           number(10)      DEFAULT 0                 NOT NULL,
15	attempt_ip               nvarchar2(39)   DEFAULT ''                ,
16	attempt_clock            number(10)      DEFAULT 0                 NOT NULL,
17	rows_per_page            number(10)      DEFAULT 50                NOT NULL,
18	PRIMARY KEY (userid)
19);
20CREATE UNIQUE INDEX users_1 ON users (alias);
21CREATE TABLE maintenances (
22	maintenanceid            number(20)                                NOT NULL,
23	name                     nvarchar2(128)  DEFAULT ''                ,
24	maintenance_type         number(10)      DEFAULT '0'               NOT NULL,
25	description              nvarchar2(2048) DEFAULT ''                ,
26	active_since             number(10)      DEFAULT '0'               NOT NULL,
27	active_till              number(10)      DEFAULT '0'               NOT NULL,
28	tags_evaltype            number(10)      DEFAULT '0'               NOT NULL,
29	PRIMARY KEY (maintenanceid)
30);
31CREATE INDEX maintenances_1 ON maintenances (active_since,active_till);
32CREATE UNIQUE INDEX maintenances_2 ON maintenances (name);
33CREATE TABLE hosts (
34	hostid                   number(20)                                NOT NULL,
35	proxy_hostid             number(20)                                NULL,
36	host                     nvarchar2(128)  DEFAULT ''                ,
37	status                   number(10)      DEFAULT '0'               NOT NULL,
38	disable_until            number(10)      DEFAULT '0'               NOT NULL,
39	error                    nvarchar2(2048) DEFAULT ''                ,
40	available                number(10)      DEFAULT '0'               NOT NULL,
41	errors_from              number(10)      DEFAULT '0'               NOT NULL,
42	lastaccess               number(10)      DEFAULT '0'               NOT NULL,
43	ipmi_authtype            number(10)      DEFAULT '-1'              NOT NULL,
44	ipmi_privilege           number(10)      DEFAULT '2'               NOT NULL,
45	ipmi_username            nvarchar2(16)   DEFAULT ''                ,
46	ipmi_password            nvarchar2(20)   DEFAULT ''                ,
47	ipmi_disable_until       number(10)      DEFAULT '0'               NOT NULL,
48	ipmi_available           number(10)      DEFAULT '0'               NOT NULL,
49	snmp_disable_until       number(10)      DEFAULT '0'               NOT NULL,
50	snmp_available           number(10)      DEFAULT '0'               NOT NULL,
51	maintenanceid            number(20)                                NULL,
52	maintenance_status       number(10)      DEFAULT '0'               NOT NULL,
53	maintenance_type         number(10)      DEFAULT '0'               NOT NULL,
54	maintenance_from         number(10)      DEFAULT '0'               NOT NULL,
55	ipmi_errors_from         number(10)      DEFAULT '0'               NOT NULL,
56	snmp_errors_from         number(10)      DEFAULT '0'               NOT NULL,
57	ipmi_error               nvarchar2(2048) DEFAULT ''                ,
58	snmp_error               nvarchar2(2048) DEFAULT ''                ,
59	jmx_disable_until        number(10)      DEFAULT '0'               NOT NULL,
60	jmx_available            number(10)      DEFAULT '0'               NOT NULL,
61	jmx_errors_from          number(10)      DEFAULT '0'               NOT NULL,
62	jmx_error                nvarchar2(2048) DEFAULT ''                ,
63	name                     nvarchar2(128)  DEFAULT ''                ,
64	flags                    number(10)      DEFAULT '0'               NOT NULL,
65	templateid               number(20)                                NULL,
66	description              nvarchar2(2048) DEFAULT ''                ,
67	tls_connect              number(10)      DEFAULT '1'               NOT NULL,
68	tls_accept               number(10)      DEFAULT '1'               NOT NULL,
69	tls_issuer               nvarchar2(1024) DEFAULT ''                ,
70	tls_subject              nvarchar2(1024) DEFAULT ''                ,
71	tls_psk_identity         nvarchar2(128)  DEFAULT ''                ,
72	tls_psk                  nvarchar2(512)  DEFAULT ''                ,
73	proxy_address            nvarchar2(255)  DEFAULT ''                ,
74	auto_compress            number(10)      DEFAULT '1'               NOT NULL,
75	PRIMARY KEY (hostid)
76);
77CREATE INDEX hosts_1 ON hosts (host);
78CREATE INDEX hosts_2 ON hosts (status);
79CREATE INDEX hosts_3 ON hosts (proxy_hostid);
80CREATE INDEX hosts_4 ON hosts (name);
81CREATE INDEX hosts_5 ON hosts (maintenanceid);
82CREATE TABLE hstgrp (
83	groupid                  number(20)                                NOT NULL,
84	name                     nvarchar2(255)  DEFAULT ''                ,
85	internal                 number(10)      DEFAULT '0'               NOT NULL,
86	flags                    number(10)      DEFAULT '0'               NOT NULL,
87	PRIMARY KEY (groupid)
88);
89CREATE INDEX hstgrp_1 ON hstgrp (name);
90CREATE TABLE group_prototype (
91	group_prototypeid        number(20)                                NOT NULL,
92	hostid                   number(20)                                NOT NULL,
93	name                     nvarchar2(255)  DEFAULT ''                ,
94	groupid                  number(20)                                NULL,
95	templateid               number(20)                                NULL,
96	PRIMARY KEY (group_prototypeid)
97);
98CREATE INDEX group_prototype_1 ON group_prototype (hostid);
99CREATE TABLE group_discovery (
100	groupid                  number(20)                                NOT NULL,
101	parent_group_prototypeid number(20)                                NOT NULL,
102	name                     nvarchar2(64)   DEFAULT ''                ,
103	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
104	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
105	PRIMARY KEY (groupid)
106);
107CREATE TABLE screens (
108	screenid                 number(20)                                NOT NULL,
109	name                     nvarchar2(255)                            ,
110	hsize                    number(10)      DEFAULT '1'               NOT NULL,
111	vsize                    number(10)      DEFAULT '1'               NOT NULL,
112	templateid               number(20)                                NULL,
113	userid                   number(20)                                NULL,
114	private                  number(10)      DEFAULT '1'               NOT NULL,
115	PRIMARY KEY (screenid)
116);
117CREATE INDEX screens_1 ON screens (templateid);
118CREATE TABLE screens_items (
119	screenitemid             number(20)                                NOT NULL,
120	screenid                 number(20)                                NOT NULL,
121	resourcetype             number(10)      DEFAULT '0'               NOT NULL,
122	resourceid               number(20)      DEFAULT '0'               NOT NULL,
123	width                    number(10)      DEFAULT '320'             NOT NULL,
124	height                   number(10)      DEFAULT '200'             NOT NULL,
125	x                        number(10)      DEFAULT '0'               NOT NULL,
126	y                        number(10)      DEFAULT '0'               NOT NULL,
127	colspan                  number(10)      DEFAULT '1'               NOT NULL,
128	rowspan                  number(10)      DEFAULT '1'               NOT NULL,
129	elements                 number(10)      DEFAULT '25'              NOT NULL,
130	valign                   number(10)      DEFAULT '0'               NOT NULL,
131	halign                   number(10)      DEFAULT '0'               NOT NULL,
132	style                    number(10)      DEFAULT '0'               NOT NULL,
133	url                      nvarchar2(255)  DEFAULT ''                ,
134	dynamic                  number(10)      DEFAULT '0'               NOT NULL,
135	sort_triggers            number(10)      DEFAULT '0'               NOT NULL,
136	application              nvarchar2(255)  DEFAULT ''                ,
137	max_columns              number(10)      DEFAULT '3'               NOT NULL,
138	PRIMARY KEY (screenitemid)
139);
140CREATE INDEX screens_items_1 ON screens_items (screenid);
141CREATE TABLE screen_user (
142	screenuserid             number(20)                                NOT NULL,
143	screenid                 number(20)                                NOT NULL,
144	userid                   number(20)                                NOT NULL,
145	permission               number(10)      DEFAULT '2'               NOT NULL,
146	PRIMARY KEY (screenuserid)
147);
148CREATE UNIQUE INDEX screen_user_1 ON screen_user (screenid,userid);
149CREATE TABLE screen_usrgrp (
150	screenusrgrpid           number(20)                                NOT NULL,
151	screenid                 number(20)                                NOT NULL,
152	usrgrpid                 number(20)                                NOT NULL,
153	permission               number(10)      DEFAULT '2'               NOT NULL,
154	PRIMARY KEY (screenusrgrpid)
155);
156CREATE UNIQUE INDEX screen_usrgrp_1 ON screen_usrgrp (screenid,usrgrpid);
157CREATE TABLE slideshows (
158	slideshowid              number(20)                                NOT NULL,
159	name                     nvarchar2(255)  DEFAULT ''                ,
160	delay                    nvarchar2(32)   DEFAULT '30s'             ,
161	userid                   number(20)                                NOT NULL,
162	private                  number(10)      DEFAULT '1'               NOT NULL,
163	PRIMARY KEY (slideshowid)
164);
165CREATE UNIQUE INDEX slideshows_1 ON slideshows (name);
166CREATE TABLE slideshow_user (
167	slideshowuserid          number(20)                                NOT NULL,
168	slideshowid              number(20)                                NOT NULL,
169	userid                   number(20)                                NOT NULL,
170	permission               number(10)      DEFAULT '2'               NOT NULL,
171	PRIMARY KEY (slideshowuserid)
172);
173CREATE UNIQUE INDEX slideshow_user_1 ON slideshow_user (slideshowid,userid);
174CREATE TABLE slideshow_usrgrp (
175	slideshowusrgrpid        number(20)                                NOT NULL,
176	slideshowid              number(20)                                NOT NULL,
177	usrgrpid                 number(20)                                NOT NULL,
178	permission               number(10)      DEFAULT '2'               NOT NULL,
179	PRIMARY KEY (slideshowusrgrpid)
180);
181CREATE UNIQUE INDEX slideshow_usrgrp_1 ON slideshow_usrgrp (slideshowid,usrgrpid);
182CREATE TABLE slides (
183	slideid                  number(20)                                NOT NULL,
184	slideshowid              number(20)                                NOT NULL,
185	screenid                 number(20)                                NOT NULL,
186	step                     number(10)      DEFAULT '0'               NOT NULL,
187	delay                    nvarchar2(32)   DEFAULT '0'               ,
188	PRIMARY KEY (slideid)
189);
190CREATE INDEX slides_1 ON slides (slideshowid);
191CREATE INDEX slides_2 ON slides (screenid);
192CREATE TABLE drules (
193	druleid                  number(20)                                NOT NULL,
194	proxy_hostid             number(20)                                NULL,
195	name                     nvarchar2(255)  DEFAULT ''                ,
196	iprange                  nvarchar2(2048) DEFAULT ''                ,
197	delay                    nvarchar2(255)  DEFAULT '1h'              ,
198	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
199	status                   number(10)      DEFAULT '0'               NOT NULL,
200	PRIMARY KEY (druleid)
201);
202CREATE INDEX drules_1 ON drules (proxy_hostid);
203CREATE UNIQUE INDEX drules_2 ON drules (name);
204CREATE TABLE dchecks (
205	dcheckid                 number(20)                                NOT NULL,
206	druleid                  number(20)                                NOT NULL,
207	type                     number(10)      DEFAULT '0'               NOT NULL,
208	key_                     nvarchar2(512)  DEFAULT ''                ,
209	snmp_community           nvarchar2(255)  DEFAULT ''                ,
210	ports                    nvarchar2(255)  DEFAULT '0'               ,
211	snmpv3_securityname      nvarchar2(64)   DEFAULT ''                ,
212	snmpv3_securitylevel     number(10)      DEFAULT '0'               NOT NULL,
213	snmpv3_authpassphrase    nvarchar2(64)   DEFAULT ''                ,
214	snmpv3_privpassphrase    nvarchar2(64)   DEFAULT ''                ,
215	uniq                     number(10)      DEFAULT '0'               NOT NULL,
216	snmpv3_authprotocol      number(10)      DEFAULT '0'               NOT NULL,
217	snmpv3_privprotocol      number(10)      DEFAULT '0'               NOT NULL,
218	snmpv3_contextname       nvarchar2(255)  DEFAULT ''                ,
219	PRIMARY KEY (dcheckid)
220);
221CREATE INDEX dchecks_1 ON dchecks (druleid);
222CREATE TABLE applications (
223	applicationid            number(20)                                NOT NULL,
224	hostid                   number(20)                                NOT NULL,
225	name                     nvarchar2(255)  DEFAULT ''                ,
226	flags                    number(10)      DEFAULT '0'               NOT NULL,
227	PRIMARY KEY (applicationid)
228);
229CREATE UNIQUE INDEX applications_2 ON applications (hostid,name);
230CREATE TABLE httptest (
231	httptestid               number(20)                                NOT NULL,
232	name                     nvarchar2(64)   DEFAULT ''                ,
233	applicationid            number(20)                                NULL,
234	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
235	delay                    nvarchar2(255)  DEFAULT '1m'              ,
236	status                   number(10)      DEFAULT '0'               NOT NULL,
237	agent                    nvarchar2(255)  DEFAULT 'Zabbix'          ,
238	authentication           number(10)      DEFAULT '0'               NOT NULL,
239	http_user                nvarchar2(64)   DEFAULT ''                ,
240	http_password            nvarchar2(64)   DEFAULT ''                ,
241	hostid                   number(20)                                NOT NULL,
242	templateid               number(20)                                NULL,
243	http_proxy               nvarchar2(255)  DEFAULT ''                ,
244	retries                  number(10)      DEFAULT '1'               NOT NULL,
245	ssl_cert_file            nvarchar2(255)  DEFAULT ''                ,
246	ssl_key_file             nvarchar2(255)  DEFAULT ''                ,
247	ssl_key_password         nvarchar2(64)   DEFAULT ''                ,
248	verify_peer              number(10)      DEFAULT '0'               NOT NULL,
249	verify_host              number(10)      DEFAULT '0'               NOT NULL,
250	PRIMARY KEY (httptestid)
251);
252CREATE INDEX httptest_1 ON httptest (applicationid);
253CREATE UNIQUE INDEX httptest_2 ON httptest (hostid,name);
254CREATE INDEX httptest_3 ON httptest (status);
255CREATE INDEX httptest_4 ON httptest (templateid);
256CREATE TABLE httpstep (
257	httpstepid               number(20)                                NOT NULL,
258	httptestid               number(20)                                NOT NULL,
259	name                     nvarchar2(64)   DEFAULT ''                ,
260	no                       number(10)      DEFAULT '0'               NOT NULL,
261	url                      nvarchar2(2048) DEFAULT ''                ,
262	timeout                  nvarchar2(255)  DEFAULT '15s'             ,
263	posts                    nvarchar2(2048) DEFAULT ''                ,
264	required                 nvarchar2(255)  DEFAULT ''                ,
265	status_codes             nvarchar2(255)  DEFAULT ''                ,
266	follow_redirects         number(10)      DEFAULT '1'               NOT NULL,
267	retrieve_mode            number(10)      DEFAULT '0'               NOT NULL,
268	post_type                number(10)      DEFAULT '0'               NOT NULL,
269	PRIMARY KEY (httpstepid)
270);
271CREATE INDEX httpstep_1 ON httpstep (httptestid);
272CREATE TABLE interface (
273	interfaceid              number(20)                                NOT NULL,
274	hostid                   number(20)                                NOT NULL,
275	main                     number(10)      DEFAULT '0'               NOT NULL,
276	type                     number(10)      DEFAULT '0'               NOT NULL,
277	useip                    number(10)      DEFAULT '1'               NOT NULL,
278	ip                       nvarchar2(64)   DEFAULT '127.0.0.1'       ,
279	dns                      nvarchar2(255)  DEFAULT ''                ,
280	port                     nvarchar2(64)   DEFAULT '10050'           ,
281	bulk                     number(10)      DEFAULT '1'               NOT NULL,
282	PRIMARY KEY (interfaceid)
283);
284CREATE INDEX interface_1 ON interface (hostid,type);
285CREATE INDEX interface_2 ON interface (ip,dns);
286CREATE TABLE valuemaps (
287	valuemapid               number(20)                                NOT NULL,
288	name                     nvarchar2(64)   DEFAULT ''                ,
289	PRIMARY KEY (valuemapid)
290);
291CREATE UNIQUE INDEX valuemaps_1 ON valuemaps (name);
292CREATE TABLE items (
293	itemid                   number(20)                                NOT NULL,
294	type                     number(10)      DEFAULT '0'               NOT NULL,
295	snmp_community           nvarchar2(64)   DEFAULT ''                ,
296	snmp_oid                 nvarchar2(512)  DEFAULT ''                ,
297	hostid                   number(20)                                NOT NULL,
298	name                     nvarchar2(255)  DEFAULT ''                ,
299	key_                     nvarchar2(255)  DEFAULT ''                ,
300	delay                    nvarchar2(1024) DEFAULT '0'               ,
301	history                  nvarchar2(255)  DEFAULT '90d'             ,
302	trends                   nvarchar2(255)  DEFAULT '365d'            ,
303	status                   number(10)      DEFAULT '0'               NOT NULL,
304	value_type               number(10)      DEFAULT '0'               NOT NULL,
305	trapper_hosts            nvarchar2(255)  DEFAULT ''                ,
306	units                    nvarchar2(255)  DEFAULT ''                ,
307	snmpv3_securityname      nvarchar2(64)   DEFAULT ''                ,
308	snmpv3_securitylevel     number(10)      DEFAULT '0'               NOT NULL,
309	snmpv3_authpassphrase    nvarchar2(64)   DEFAULT ''                ,
310	snmpv3_privpassphrase    nvarchar2(64)   DEFAULT ''                ,
311	formula                  nvarchar2(255)  DEFAULT ''                ,
312	error                    nvarchar2(2048) DEFAULT ''                ,
313	lastlogsize              number(20)      DEFAULT '0'               NOT NULL,
314	logtimefmt               nvarchar2(64)   DEFAULT ''                ,
315	templateid               number(20)                                NULL,
316	valuemapid               number(20)                                NULL,
317	params                   nvarchar2(2048) DEFAULT ''                ,
318	ipmi_sensor              nvarchar2(128)  DEFAULT ''                ,
319	authtype                 number(10)      DEFAULT '0'               NOT NULL,
320	username                 nvarchar2(64)   DEFAULT ''                ,
321	password                 nvarchar2(64)   DEFAULT ''                ,
322	publickey                nvarchar2(64)   DEFAULT ''                ,
323	privatekey               nvarchar2(64)   DEFAULT ''                ,
324	mtime                    number(10)      DEFAULT '0'               NOT NULL,
325	flags                    number(10)      DEFAULT '0'               NOT NULL,
326	interfaceid              number(20)                                NULL,
327	port                     nvarchar2(64)   DEFAULT ''                ,
328	description              nvarchar2(2048) DEFAULT ''                ,
329	inventory_link           number(10)      DEFAULT '0'               NOT NULL,
330	lifetime                 nvarchar2(255)  DEFAULT '30d'             ,
331	snmpv3_authprotocol      number(10)      DEFAULT '0'               NOT NULL,
332	snmpv3_privprotocol      number(10)      DEFAULT '0'               NOT NULL,
333	state                    number(10)      DEFAULT '0'               NOT NULL,
334	snmpv3_contextname       nvarchar2(255)  DEFAULT ''                ,
335	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
336	jmx_endpoint             nvarchar2(255)  DEFAULT ''                ,
337	master_itemid            number(20)                                NULL,
338	timeout                  nvarchar2(255)  DEFAULT '3s'              ,
339	url                      nvarchar2(2048) DEFAULT ''                ,
340	query_fields             nvarchar2(2048) DEFAULT ''                ,
341	posts                    nvarchar2(2048) DEFAULT ''                ,
342	status_codes             nvarchar2(255)  DEFAULT '200'             ,
343	follow_redirects         number(10)      DEFAULT '1'               NOT NULL,
344	post_type                number(10)      DEFAULT '0'               NOT NULL,
345	http_proxy               nvarchar2(255)  DEFAULT ''                ,
346	headers                  nvarchar2(2048) DEFAULT ''                ,
347	retrieve_mode            number(10)      DEFAULT '0'               NOT NULL,
348	request_method           number(10)      DEFAULT '0'               NOT NULL,
349	output_format            number(10)      DEFAULT '0'               NOT NULL,
350	ssl_cert_file            nvarchar2(255)  DEFAULT ''                ,
351	ssl_key_file             nvarchar2(255)  DEFAULT ''                ,
352	ssl_key_password         nvarchar2(64)   DEFAULT ''                ,
353	verify_peer              number(10)      DEFAULT '0'               NOT NULL,
354	verify_host              number(10)      DEFAULT '0'               NOT NULL,
355	allow_traps              number(10)      DEFAULT '0'               NOT NULL,
356	PRIMARY KEY (itemid)
357);
358CREATE UNIQUE INDEX items_1 ON items (hostid,key_);
359CREATE INDEX items_3 ON items (status);
360CREATE INDEX items_4 ON items (templateid);
361CREATE INDEX items_5 ON items (valuemapid);
362CREATE INDEX items_6 ON items (interfaceid);
363CREATE INDEX items_7 ON items (master_itemid);
364CREATE TABLE httpstepitem (
365	httpstepitemid           number(20)                                NOT NULL,
366	httpstepid               number(20)                                NOT NULL,
367	itemid                   number(20)                                NOT NULL,
368	type                     number(10)      DEFAULT '0'               NOT NULL,
369	PRIMARY KEY (httpstepitemid)
370);
371CREATE UNIQUE INDEX httpstepitem_1 ON httpstepitem (httpstepid,itemid);
372CREATE INDEX httpstepitem_2 ON httpstepitem (itemid);
373CREATE TABLE httptestitem (
374	httptestitemid           number(20)                                NOT NULL,
375	httptestid               number(20)                                NOT NULL,
376	itemid                   number(20)                                NOT NULL,
377	type                     number(10)      DEFAULT '0'               NOT NULL,
378	PRIMARY KEY (httptestitemid)
379);
380CREATE UNIQUE INDEX httptestitem_1 ON httptestitem (httptestid,itemid);
381CREATE INDEX httptestitem_2 ON httptestitem (itemid);
382CREATE TABLE media_type (
383	mediatypeid              number(20)                                NOT NULL,
384	type                     number(10)      DEFAULT '0'               NOT NULL,
385	description              nvarchar2(100)  DEFAULT ''                ,
386	smtp_server              nvarchar2(255)  DEFAULT ''                ,
387	smtp_helo                nvarchar2(255)  DEFAULT ''                ,
388	smtp_email               nvarchar2(255)  DEFAULT ''                ,
389	exec_path                nvarchar2(255)  DEFAULT ''                ,
390	gsm_modem                nvarchar2(255)  DEFAULT ''                ,
391	username                 nvarchar2(255)  DEFAULT ''                ,
392	passwd                   nvarchar2(255)  DEFAULT ''                ,
393	status                   number(10)      DEFAULT '0'               NOT NULL,
394	smtp_port                number(10)      DEFAULT '25'              NOT NULL,
395	smtp_security            number(10)      DEFAULT '0'               NOT NULL,
396	smtp_verify_peer         number(10)      DEFAULT '0'               NOT NULL,
397	smtp_verify_host         number(10)      DEFAULT '0'               NOT NULL,
398	smtp_authentication      number(10)      DEFAULT '0'               NOT NULL,
399	exec_params              nvarchar2(255)  DEFAULT ''                ,
400	maxsessions              number(10)      DEFAULT '1'               NOT NULL,
401	maxattempts              number(10)      DEFAULT '3'               NOT NULL,
402	attempt_interval         nvarchar2(32)   DEFAULT '10s'             ,
403	PRIMARY KEY (mediatypeid)
404);
405CREATE UNIQUE INDEX media_type_1 ON media_type (description);
406CREATE TABLE usrgrp (
407	usrgrpid                 number(20)                                NOT NULL,
408	name                     nvarchar2(64)   DEFAULT ''                ,
409	gui_access               number(10)      DEFAULT '0'               NOT NULL,
410	users_status             number(10)      DEFAULT '0'               NOT NULL,
411	debug_mode               number(10)      DEFAULT '0'               NOT NULL,
412	PRIMARY KEY (usrgrpid)
413);
414CREATE UNIQUE INDEX usrgrp_1 ON usrgrp (name);
415CREATE TABLE users_groups (
416	id                       number(20)                                NOT NULL,
417	usrgrpid                 number(20)                                NOT NULL,
418	userid                   number(20)                                NOT NULL,
419	PRIMARY KEY (id)
420);
421CREATE UNIQUE INDEX users_groups_1 ON users_groups (usrgrpid,userid);
422CREATE INDEX users_groups_2 ON users_groups (userid);
423CREATE TABLE scripts (
424	scriptid                 number(20)                                NOT NULL,
425	name                     nvarchar2(255)  DEFAULT ''                ,
426	command                  nvarchar2(255)  DEFAULT ''                ,
427	host_access              number(10)      DEFAULT '2'               NOT NULL,
428	usrgrpid                 number(20)                                NULL,
429	groupid                  number(20)                                NULL,
430	description              nvarchar2(2048) DEFAULT ''                ,
431	confirmation             nvarchar2(255)  DEFAULT ''                ,
432	type                     number(10)      DEFAULT '0'               NOT NULL,
433	execute_on               number(10)      DEFAULT '2'               NOT NULL,
434	PRIMARY KEY (scriptid)
435);
436CREATE INDEX scripts_1 ON scripts (usrgrpid);
437CREATE INDEX scripts_2 ON scripts (groupid);
438CREATE UNIQUE INDEX scripts_3 ON scripts (name);
439CREATE TABLE actions (
440	actionid                 number(20)                                NOT NULL,
441	name                     nvarchar2(255)  DEFAULT ''                ,
442	eventsource              number(10)      DEFAULT '0'               NOT NULL,
443	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
444	status                   number(10)      DEFAULT '0'               NOT NULL,
445	esc_period               nvarchar2(255)  DEFAULT '1h'              ,
446	def_shortdata            nvarchar2(255)  DEFAULT ''                ,
447	def_longdata             nvarchar2(2048) DEFAULT ''                ,
448	r_shortdata              nvarchar2(255)  DEFAULT ''                ,
449	r_longdata               nvarchar2(2048) DEFAULT ''                ,
450	formula                  nvarchar2(255)  DEFAULT ''                ,
451	pause_suppressed         number(10)      DEFAULT '1'               NOT NULL,
452	ack_shortdata            nvarchar2(255)  DEFAULT ''                ,
453	ack_longdata             nvarchar2(2048) DEFAULT ''                ,
454	PRIMARY KEY (actionid)
455);
456CREATE INDEX actions_1 ON actions (eventsource,status);
457CREATE UNIQUE INDEX actions_2 ON actions (name);
458CREATE TABLE operations (
459	operationid              number(20)                                NOT NULL,
460	actionid                 number(20)                                NOT NULL,
461	operationtype            number(10)      DEFAULT '0'               NOT NULL,
462	esc_period               nvarchar2(255)  DEFAULT '0'               ,
463	esc_step_from            number(10)      DEFAULT '1'               NOT NULL,
464	esc_step_to              number(10)      DEFAULT '1'               NOT NULL,
465	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
466	recovery                 number(10)      DEFAULT '0'               NOT NULL,
467	PRIMARY KEY (operationid)
468);
469CREATE INDEX operations_1 ON operations (actionid);
470CREATE TABLE opmessage (
471	operationid              number(20)                                NOT NULL,
472	default_msg              number(10)      DEFAULT '0'               NOT NULL,
473	subject                  nvarchar2(255)  DEFAULT ''                ,
474	message                  nvarchar2(2048) DEFAULT ''                ,
475	mediatypeid              number(20)                                NULL,
476	PRIMARY KEY (operationid)
477);
478CREATE INDEX opmessage_1 ON opmessage (mediatypeid);
479CREATE TABLE opmessage_grp (
480	opmessage_grpid          number(20)                                NOT NULL,
481	operationid              number(20)                                NOT NULL,
482	usrgrpid                 number(20)                                NOT NULL,
483	PRIMARY KEY (opmessage_grpid)
484);
485CREATE UNIQUE INDEX opmessage_grp_1 ON opmessage_grp (operationid,usrgrpid);
486CREATE INDEX opmessage_grp_2 ON opmessage_grp (usrgrpid);
487CREATE TABLE opmessage_usr (
488	opmessage_usrid          number(20)                                NOT NULL,
489	operationid              number(20)                                NOT NULL,
490	userid                   number(20)                                NOT NULL,
491	PRIMARY KEY (opmessage_usrid)
492);
493CREATE UNIQUE INDEX opmessage_usr_1 ON opmessage_usr (operationid,userid);
494CREATE INDEX opmessage_usr_2 ON opmessage_usr (userid);
495CREATE TABLE opcommand (
496	operationid              number(20)                                NOT NULL,
497	type                     number(10)      DEFAULT '0'               NOT NULL,
498	scriptid                 number(20)                                NULL,
499	execute_on               number(10)      DEFAULT '0'               NOT NULL,
500	port                     nvarchar2(64)   DEFAULT ''                ,
501	authtype                 number(10)      DEFAULT '0'               NOT NULL,
502	username                 nvarchar2(64)   DEFAULT ''                ,
503	password                 nvarchar2(64)   DEFAULT ''                ,
504	publickey                nvarchar2(64)   DEFAULT ''                ,
505	privatekey               nvarchar2(64)   DEFAULT ''                ,
506	command                  nvarchar2(2048) DEFAULT ''                ,
507	PRIMARY KEY (operationid)
508);
509CREATE INDEX opcommand_1 ON opcommand (scriptid);
510CREATE TABLE opcommand_hst (
511	opcommand_hstid          number(20)                                NOT NULL,
512	operationid              number(20)                                NOT NULL,
513	hostid                   number(20)                                NULL,
514	PRIMARY KEY (opcommand_hstid)
515);
516CREATE INDEX opcommand_hst_1 ON opcommand_hst (operationid);
517CREATE INDEX opcommand_hst_2 ON opcommand_hst (hostid);
518CREATE TABLE opcommand_grp (
519	opcommand_grpid          number(20)                                NOT NULL,
520	operationid              number(20)                                NOT NULL,
521	groupid                  number(20)                                NOT NULL,
522	PRIMARY KEY (opcommand_grpid)
523);
524CREATE INDEX opcommand_grp_1 ON opcommand_grp (operationid);
525CREATE INDEX opcommand_grp_2 ON opcommand_grp (groupid);
526CREATE TABLE opgroup (
527	opgroupid                number(20)                                NOT NULL,
528	operationid              number(20)                                NOT NULL,
529	groupid                  number(20)                                NOT NULL,
530	PRIMARY KEY (opgroupid)
531);
532CREATE UNIQUE INDEX opgroup_1 ON opgroup (operationid,groupid);
533CREATE INDEX opgroup_2 ON opgroup (groupid);
534CREATE TABLE optemplate (
535	optemplateid             number(20)                                NOT NULL,
536	operationid              number(20)                                NOT NULL,
537	templateid               number(20)                                NOT NULL,
538	PRIMARY KEY (optemplateid)
539);
540CREATE UNIQUE INDEX optemplate_1 ON optemplate (operationid,templateid);
541CREATE INDEX optemplate_2 ON optemplate (templateid);
542CREATE TABLE opconditions (
543	opconditionid            number(20)                                NOT NULL,
544	operationid              number(20)                                NOT NULL,
545	conditiontype            number(10)      DEFAULT '0'               NOT NULL,
546	operator                 number(10)      DEFAULT '0'               NOT NULL,
547	value                    nvarchar2(255)  DEFAULT ''                ,
548	PRIMARY KEY (opconditionid)
549);
550CREATE INDEX opconditions_1 ON opconditions (operationid);
551CREATE TABLE conditions (
552	conditionid              number(20)                                NOT NULL,
553	actionid                 number(20)                                NOT NULL,
554	conditiontype            number(10)      DEFAULT '0'               NOT NULL,
555	operator                 number(10)      DEFAULT '0'               NOT NULL,
556	value                    nvarchar2(255)  DEFAULT ''                ,
557	value2                   nvarchar2(255)  DEFAULT ''                ,
558	PRIMARY KEY (conditionid)
559);
560CREATE INDEX conditions_1 ON conditions (actionid);
561CREATE TABLE config (
562	configid                 number(20)                                NOT NULL,
563	refresh_unsupported      nvarchar2(32)   DEFAULT '10m'             ,
564	work_period              nvarchar2(255)  DEFAULT '1-5,09:00-18:00' ,
565	alert_usrgrpid           number(20)                                NULL,
566	default_theme            nvarchar2(128)  DEFAULT 'blue-theme'      ,
567	authentication_type      number(10)      DEFAULT '0'               NOT NULL,
568	ldap_host                nvarchar2(255)  DEFAULT ''                ,
569	ldap_port                number(10)      DEFAULT 389               NOT NULL,
570	ldap_base_dn             nvarchar2(255)  DEFAULT ''                ,
571	ldap_bind_dn             nvarchar2(255)  DEFAULT ''                ,
572	ldap_bind_password       nvarchar2(128)  DEFAULT ''                ,
573	ldap_search_attribute    nvarchar2(128)  DEFAULT ''                ,
574	dropdown_first_entry     number(10)      DEFAULT '1'               NOT NULL,
575	dropdown_first_remember  number(10)      DEFAULT '1'               NOT NULL,
576	discovery_groupid        number(20)                                NOT NULL,
577	max_in_table             number(10)      DEFAULT '50'              NOT NULL,
578	search_limit             number(10)      DEFAULT '1000'            NOT NULL,
579	severity_color_0         nvarchar2(6)    DEFAULT '97AAB3'          ,
580	severity_color_1         nvarchar2(6)    DEFAULT '7499FF'          ,
581	severity_color_2         nvarchar2(6)    DEFAULT 'FFC859'          ,
582	severity_color_3         nvarchar2(6)    DEFAULT 'FFA059'          ,
583	severity_color_4         nvarchar2(6)    DEFAULT 'E97659'          ,
584	severity_color_5         nvarchar2(6)    DEFAULT 'E45959'          ,
585	severity_name_0          nvarchar2(32)   DEFAULT 'Not classified'  ,
586	severity_name_1          nvarchar2(32)   DEFAULT 'Information'     ,
587	severity_name_2          nvarchar2(32)   DEFAULT 'Warning'         ,
588	severity_name_3          nvarchar2(32)   DEFAULT 'Average'         ,
589	severity_name_4          nvarchar2(32)   DEFAULT 'High'            ,
590	severity_name_5          nvarchar2(32)   DEFAULT 'Disaster'        ,
591	ok_period                nvarchar2(32)   DEFAULT '5m'              ,
592	blink_period             nvarchar2(32)   DEFAULT '2m'              ,
593	problem_unack_color      nvarchar2(6)    DEFAULT 'CC0000'          ,
594	problem_ack_color        nvarchar2(6)    DEFAULT 'CC0000'          ,
595	ok_unack_color           nvarchar2(6)    DEFAULT '009900'          ,
596	ok_ack_color             nvarchar2(6)    DEFAULT '009900'          ,
597	problem_unack_style      number(10)      DEFAULT '1'               NOT NULL,
598	problem_ack_style        number(10)      DEFAULT '1'               NOT NULL,
599	ok_unack_style           number(10)      DEFAULT '1'               NOT NULL,
600	ok_ack_style             number(10)      DEFAULT '1'               NOT NULL,
601	snmptrap_logging         number(10)      DEFAULT '1'               NOT NULL,
602	server_check_interval    number(10)      DEFAULT '10'              NOT NULL,
603	hk_events_mode           number(10)      DEFAULT '1'               NOT NULL,
604	hk_events_trigger        nvarchar2(32)   DEFAULT '365d'            ,
605	hk_events_internal       nvarchar2(32)   DEFAULT '1d'              ,
606	hk_events_discovery      nvarchar2(32)   DEFAULT '1d'              ,
607	hk_events_autoreg        nvarchar2(32)   DEFAULT '1d'              ,
608	hk_services_mode         number(10)      DEFAULT '1'               NOT NULL,
609	hk_services              nvarchar2(32)   DEFAULT '365d'            ,
610	hk_audit_mode            number(10)      DEFAULT '1'               NOT NULL,
611	hk_audit                 nvarchar2(32)   DEFAULT '365d'            ,
612	hk_sessions_mode         number(10)      DEFAULT '1'               NOT NULL,
613	hk_sessions              nvarchar2(32)   DEFAULT '365d'            ,
614	hk_history_mode          number(10)      DEFAULT '1'               NOT NULL,
615	hk_history_global        number(10)      DEFAULT '0'               NOT NULL,
616	hk_history               nvarchar2(32)   DEFAULT '90d'             ,
617	hk_trends_mode           number(10)      DEFAULT '1'               NOT NULL,
618	hk_trends_global         number(10)      DEFAULT '0'               NOT NULL,
619	hk_trends                nvarchar2(32)   DEFAULT '365d'            ,
620	default_inventory_mode   number(10)      DEFAULT '-1'              NOT NULL,
621	custom_color             number(10)      DEFAULT '0'               NOT NULL,
622	http_auth_enabled        number(10)      DEFAULT '0'               NOT NULL,
623	http_login_form          number(10)      DEFAULT '0'               NOT NULL,
624	http_strip_domains       nvarchar2(2048) DEFAULT ''                ,
625	http_case_sensitive      number(10)      DEFAULT '1'               NOT NULL,
626	ldap_configured          number(10)      DEFAULT '0'               NOT NULL,
627	ldap_case_sensitive      number(10)      DEFAULT '1'               NOT NULL,
628	PRIMARY KEY (configid)
629);
630CREATE INDEX config_1 ON config (alert_usrgrpid);
631CREATE INDEX config_2 ON config (discovery_groupid);
632CREATE TABLE triggers (
633	triggerid                number(20)                                NOT NULL,
634	expression               nvarchar2(2048) DEFAULT ''                ,
635	description              nvarchar2(255)  DEFAULT ''                ,
636	url                      nvarchar2(255)  DEFAULT ''                ,
637	status                   number(10)      DEFAULT '0'               NOT NULL,
638	value                    number(10)      DEFAULT '0'               NOT NULL,
639	priority                 number(10)      DEFAULT '0'               NOT NULL,
640	lastchange               number(10)      DEFAULT '0'               NOT NULL,
641	comments                 nvarchar2(2048) DEFAULT ''                ,
642	error                    nvarchar2(2048) DEFAULT ''                ,
643	templateid               number(20)                                NULL,
644	type                     number(10)      DEFAULT '0'               NOT NULL,
645	state                    number(10)      DEFAULT '0'               NOT NULL,
646	flags                    number(10)      DEFAULT '0'               NOT NULL,
647	recovery_mode            number(10)      DEFAULT '0'               NOT NULL,
648	recovery_expression      nvarchar2(2048) DEFAULT ''                ,
649	correlation_mode         number(10)      DEFAULT '0'               NOT NULL,
650	correlation_tag          nvarchar2(255)  DEFAULT ''                ,
651	manual_close             number(10)      DEFAULT '0'               NOT NULL,
652	PRIMARY KEY (triggerid)
653);
654CREATE INDEX triggers_1 ON triggers (status);
655CREATE INDEX triggers_2 ON triggers (value,lastchange);
656CREATE INDEX triggers_3 ON triggers (templateid);
657CREATE TABLE trigger_depends (
658	triggerdepid             number(20)                                NOT NULL,
659	triggerid_down           number(20)                                NOT NULL,
660	triggerid_up             number(20)                                NOT NULL,
661	PRIMARY KEY (triggerdepid)
662);
663CREATE UNIQUE INDEX trigger_depends_1 ON trigger_depends (triggerid_down,triggerid_up);
664CREATE INDEX trigger_depends_2 ON trigger_depends (triggerid_up);
665CREATE TABLE functions (
666	functionid               number(20)                                NOT NULL,
667	itemid                   number(20)                                NOT NULL,
668	triggerid                number(20)                                NOT NULL,
669	name                     nvarchar2(12)   DEFAULT ''                ,
670	parameter                nvarchar2(255)  DEFAULT '0'               ,
671	PRIMARY KEY (functionid)
672);
673CREATE INDEX functions_1 ON functions (triggerid);
674CREATE INDEX functions_2 ON functions (itemid,name,parameter);
675CREATE TABLE graphs (
676	graphid                  number(20)                                NOT NULL,
677	name                     nvarchar2(128)  DEFAULT ''                ,
678	width                    number(10)      DEFAULT '900'             NOT NULL,
679	height                   number(10)      DEFAULT '200'             NOT NULL,
680	yaxismin                 number(20,4)    DEFAULT '0'               NOT NULL,
681	yaxismax                 number(20,4)    DEFAULT '100'             NOT NULL,
682	templateid               number(20)                                NULL,
683	show_work_period         number(10)      DEFAULT '1'               NOT NULL,
684	show_triggers            number(10)      DEFAULT '1'               NOT NULL,
685	graphtype                number(10)      DEFAULT '0'               NOT NULL,
686	show_legend              number(10)      DEFAULT '1'               NOT NULL,
687	show_3d                  number(10)      DEFAULT '0'               NOT NULL,
688	percent_left             number(20,4)    DEFAULT '0'               NOT NULL,
689	percent_right            number(20,4)    DEFAULT '0'               NOT NULL,
690	ymin_type                number(10)      DEFAULT '0'               NOT NULL,
691	ymax_type                number(10)      DEFAULT '0'               NOT NULL,
692	ymin_itemid              number(20)                                NULL,
693	ymax_itemid              number(20)                                NULL,
694	flags                    number(10)      DEFAULT '0'               NOT NULL,
695	PRIMARY KEY (graphid)
696);
697CREATE INDEX graphs_1 ON graphs (name);
698CREATE INDEX graphs_2 ON graphs (templateid);
699CREATE INDEX graphs_3 ON graphs (ymin_itemid);
700CREATE INDEX graphs_4 ON graphs (ymax_itemid);
701CREATE TABLE graphs_items (
702	gitemid                  number(20)                                NOT NULL,
703	graphid                  number(20)                                NOT NULL,
704	itemid                   number(20)                                NOT NULL,
705	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
706	sortorder                number(10)      DEFAULT '0'               NOT NULL,
707	color                    nvarchar2(6)    DEFAULT '009600'          ,
708	yaxisside                number(10)      DEFAULT '0'               NOT NULL,
709	calc_fnc                 number(10)      DEFAULT '2'               NOT NULL,
710	type                     number(10)      DEFAULT '0'               NOT NULL,
711	PRIMARY KEY (gitemid)
712);
713CREATE INDEX graphs_items_1 ON graphs_items (itemid);
714CREATE INDEX graphs_items_2 ON graphs_items (graphid);
715CREATE TABLE graph_theme (
716	graphthemeid             number(20)                                NOT NULL,
717	theme                    nvarchar2(64)   DEFAULT ''                ,
718	backgroundcolor          nvarchar2(6)    DEFAULT ''                ,
719	graphcolor               nvarchar2(6)    DEFAULT ''                ,
720	gridcolor                nvarchar2(6)    DEFAULT ''                ,
721	maingridcolor            nvarchar2(6)    DEFAULT ''                ,
722	gridbordercolor          nvarchar2(6)    DEFAULT ''                ,
723	textcolor                nvarchar2(6)    DEFAULT ''                ,
724	highlightcolor           nvarchar2(6)    DEFAULT ''                ,
725	leftpercentilecolor      nvarchar2(6)    DEFAULT ''                ,
726	rightpercentilecolor     nvarchar2(6)    DEFAULT ''                ,
727	nonworktimecolor         nvarchar2(6)    DEFAULT ''                ,
728	colorpalette             nvarchar2(255)  DEFAULT ''                ,
729	PRIMARY KEY (graphthemeid)
730);
731CREATE UNIQUE INDEX graph_theme_1 ON graph_theme (theme);
732CREATE TABLE globalmacro (
733	globalmacroid            number(20)                                NOT NULL,
734	macro                    nvarchar2(255)  DEFAULT ''                ,
735	value                    nvarchar2(255)  DEFAULT ''                ,
736	PRIMARY KEY (globalmacroid)
737);
738CREATE UNIQUE INDEX globalmacro_1 ON globalmacro (macro);
739CREATE TABLE hostmacro (
740	hostmacroid              number(20)                                NOT NULL,
741	hostid                   number(20)                                NOT NULL,
742	macro                    nvarchar2(255)  DEFAULT ''                ,
743	value                    nvarchar2(255)  DEFAULT ''                ,
744	PRIMARY KEY (hostmacroid)
745);
746CREATE UNIQUE INDEX hostmacro_1 ON hostmacro (hostid,macro);
747CREATE TABLE hosts_groups (
748	hostgroupid              number(20)                                NOT NULL,
749	hostid                   number(20)                                NOT NULL,
750	groupid                  number(20)                                NOT NULL,
751	PRIMARY KEY (hostgroupid)
752);
753CREATE UNIQUE INDEX hosts_groups_1 ON hosts_groups (hostid,groupid);
754CREATE INDEX hosts_groups_2 ON hosts_groups (groupid);
755CREATE TABLE hosts_templates (
756	hosttemplateid           number(20)                                NOT NULL,
757	hostid                   number(20)                                NOT NULL,
758	templateid               number(20)                                NOT NULL,
759	PRIMARY KEY (hosttemplateid)
760);
761CREATE UNIQUE INDEX hosts_templates_1 ON hosts_templates (hostid,templateid);
762CREATE INDEX hosts_templates_2 ON hosts_templates (templateid);
763CREATE TABLE items_applications (
764	itemappid                number(20)                                NOT NULL,
765	applicationid            number(20)                                NOT NULL,
766	itemid                   number(20)                                NOT NULL,
767	PRIMARY KEY (itemappid)
768);
769CREATE UNIQUE INDEX items_applications_1 ON items_applications (applicationid,itemid);
770CREATE INDEX items_applications_2 ON items_applications (itemid);
771CREATE TABLE mappings (
772	mappingid                number(20)                                NOT NULL,
773	valuemapid               number(20)                                NOT NULL,
774	value                    nvarchar2(64)   DEFAULT ''                ,
775	newvalue                 nvarchar2(64)   DEFAULT ''                ,
776	PRIMARY KEY (mappingid)
777);
778CREATE INDEX mappings_1 ON mappings (valuemapid);
779CREATE TABLE media (
780	mediaid                  number(20)                                NOT NULL,
781	userid                   number(20)                                NOT NULL,
782	mediatypeid              number(20)                                NOT NULL,
783	sendto                   nvarchar2(1024) DEFAULT ''                ,
784	active                   number(10)      DEFAULT '0'               NOT NULL,
785	severity                 number(10)      DEFAULT '63'              NOT NULL,
786	period                   nvarchar2(1024) DEFAULT '1-7,00:00-24:00' ,
787	PRIMARY KEY (mediaid)
788);
789CREATE INDEX media_1 ON media (userid);
790CREATE INDEX media_2 ON media (mediatypeid);
791CREATE TABLE rights (
792	rightid                  number(20)                                NOT NULL,
793	groupid                  number(20)                                NOT NULL,
794	permission               number(10)      DEFAULT '0'               NOT NULL,
795	id                       number(20)                                NOT NULL,
796	PRIMARY KEY (rightid)
797);
798CREATE INDEX rights_1 ON rights (groupid);
799CREATE INDEX rights_2 ON rights (id);
800CREATE TABLE services (
801	serviceid                number(20)                                NOT NULL,
802	name                     nvarchar2(128)  DEFAULT ''                ,
803	status                   number(10)      DEFAULT '0'               NOT NULL,
804	algorithm                number(10)      DEFAULT '0'               NOT NULL,
805	triggerid                number(20)                                NULL,
806	showsla                  number(10)      DEFAULT '0'               NOT NULL,
807	goodsla                  number(20,4)    DEFAULT '99.9'            NOT NULL,
808	sortorder                number(10)      DEFAULT '0'               NOT NULL,
809	PRIMARY KEY (serviceid)
810);
811CREATE INDEX services_1 ON services (triggerid);
812CREATE TABLE services_links (
813	linkid                   number(20)                                NOT NULL,
814	serviceupid              number(20)                                NOT NULL,
815	servicedownid            number(20)                                NOT NULL,
816	soft                     number(10)      DEFAULT '0'               NOT NULL,
817	PRIMARY KEY (linkid)
818);
819CREATE INDEX services_links_1 ON services_links (servicedownid);
820CREATE UNIQUE INDEX services_links_2 ON services_links (serviceupid,servicedownid);
821CREATE TABLE services_times (
822	timeid                   number(20)                                NOT NULL,
823	serviceid                number(20)                                NOT NULL,
824	type                     number(10)      DEFAULT '0'               NOT NULL,
825	ts_from                  number(10)      DEFAULT '0'               NOT NULL,
826	ts_to                    number(10)      DEFAULT '0'               NOT NULL,
827	note                     nvarchar2(255)  DEFAULT ''                ,
828	PRIMARY KEY (timeid)
829);
830CREATE INDEX services_times_1 ON services_times (serviceid,type,ts_from,ts_to);
831CREATE TABLE icon_map (
832	iconmapid                number(20)                                NOT NULL,
833	name                     nvarchar2(64)   DEFAULT ''                ,
834	default_iconid           number(20)                                NOT NULL,
835	PRIMARY KEY (iconmapid)
836);
837CREATE UNIQUE INDEX icon_map_1 ON icon_map (name);
838CREATE INDEX icon_map_2 ON icon_map (default_iconid);
839CREATE TABLE icon_mapping (
840	iconmappingid            number(20)                                NOT NULL,
841	iconmapid                number(20)                                NOT NULL,
842	iconid                   number(20)                                NOT NULL,
843	inventory_link           number(10)      DEFAULT '0'               NOT NULL,
844	expression               nvarchar2(64)   DEFAULT ''                ,
845	sortorder                number(10)      DEFAULT '0'               NOT NULL,
846	PRIMARY KEY (iconmappingid)
847);
848CREATE INDEX icon_mapping_1 ON icon_mapping (iconmapid);
849CREATE INDEX icon_mapping_2 ON icon_mapping (iconid);
850CREATE TABLE sysmaps (
851	sysmapid                 number(20)                                NOT NULL,
852	name                     nvarchar2(128)  DEFAULT ''                ,
853	width                    number(10)      DEFAULT '600'             NOT NULL,
854	height                   number(10)      DEFAULT '400'             NOT NULL,
855	backgroundid             number(20)                                NULL,
856	label_type               number(10)      DEFAULT '2'               NOT NULL,
857	label_location           number(10)      DEFAULT '0'               NOT NULL,
858	highlight                number(10)      DEFAULT '1'               NOT NULL,
859	expandproblem            number(10)      DEFAULT '1'               NOT NULL,
860	markelements             number(10)      DEFAULT '0'               NOT NULL,
861	show_unack               number(10)      DEFAULT '0'               NOT NULL,
862	grid_size                number(10)      DEFAULT '50'              NOT NULL,
863	grid_show                number(10)      DEFAULT '1'               NOT NULL,
864	grid_align               number(10)      DEFAULT '1'               NOT NULL,
865	label_format             number(10)      DEFAULT '0'               NOT NULL,
866	label_type_host          number(10)      DEFAULT '2'               NOT NULL,
867	label_type_hostgroup     number(10)      DEFAULT '2'               NOT NULL,
868	label_type_trigger       number(10)      DEFAULT '2'               NOT NULL,
869	label_type_map           number(10)      DEFAULT '2'               NOT NULL,
870	label_type_image         number(10)      DEFAULT '2'               NOT NULL,
871	label_string_host        nvarchar2(255)  DEFAULT ''                ,
872	label_string_hostgroup   nvarchar2(255)  DEFAULT ''                ,
873	label_string_trigger     nvarchar2(255)  DEFAULT ''                ,
874	label_string_map         nvarchar2(255)  DEFAULT ''                ,
875	label_string_image       nvarchar2(255)  DEFAULT ''                ,
876	iconmapid                number(20)                                NULL,
877	expand_macros            number(10)      DEFAULT '0'               NOT NULL,
878	severity_min             number(10)      DEFAULT '0'               NOT NULL,
879	userid                   number(20)                                NOT NULL,
880	private                  number(10)      DEFAULT '1'               NOT NULL,
881	show_suppressed          number(10)      DEFAULT '0'               NOT NULL,
882	PRIMARY KEY (sysmapid)
883);
884CREATE UNIQUE INDEX sysmaps_1 ON sysmaps (name);
885CREATE INDEX sysmaps_2 ON sysmaps (backgroundid);
886CREATE INDEX sysmaps_3 ON sysmaps (iconmapid);
887CREATE TABLE sysmaps_elements (
888	selementid               number(20)                                NOT NULL,
889	sysmapid                 number(20)                                NOT NULL,
890	elementid                number(20)      DEFAULT '0'               NOT NULL,
891	elementtype              number(10)      DEFAULT '0'               NOT NULL,
892	iconid_off               number(20)                                NULL,
893	iconid_on                number(20)                                NULL,
894	label                    nvarchar2(2048) DEFAULT ''                ,
895	label_location           number(10)      DEFAULT '-1'              NOT NULL,
896	x                        number(10)      DEFAULT '0'               NOT NULL,
897	y                        number(10)      DEFAULT '0'               NOT NULL,
898	iconid_disabled          number(20)                                NULL,
899	iconid_maintenance       number(20)                                NULL,
900	elementsubtype           number(10)      DEFAULT '0'               NOT NULL,
901	areatype                 number(10)      DEFAULT '0'               NOT NULL,
902	width                    number(10)      DEFAULT '200'             NOT NULL,
903	height                   number(10)      DEFAULT '200'             NOT NULL,
904	viewtype                 number(10)      DEFAULT '0'               NOT NULL,
905	use_iconmap              number(10)      DEFAULT '1'               NOT NULL,
906	application              nvarchar2(255)  DEFAULT ''                ,
907	PRIMARY KEY (selementid)
908);
909CREATE INDEX sysmaps_elements_1 ON sysmaps_elements (sysmapid);
910CREATE INDEX sysmaps_elements_2 ON sysmaps_elements (iconid_off);
911CREATE INDEX sysmaps_elements_3 ON sysmaps_elements (iconid_on);
912CREATE INDEX sysmaps_elements_4 ON sysmaps_elements (iconid_disabled);
913CREATE INDEX sysmaps_elements_5 ON sysmaps_elements (iconid_maintenance);
914CREATE TABLE sysmaps_links (
915	linkid                   number(20)                                NOT NULL,
916	sysmapid                 number(20)                                NOT NULL,
917	selementid1              number(20)                                NOT NULL,
918	selementid2              number(20)                                NOT NULL,
919	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
920	color                    nvarchar2(6)    DEFAULT '000000'          ,
921	label                    nvarchar2(2048) DEFAULT ''                ,
922	PRIMARY KEY (linkid)
923);
924CREATE INDEX sysmaps_links_1 ON sysmaps_links (sysmapid);
925CREATE INDEX sysmaps_links_2 ON sysmaps_links (selementid1);
926CREATE INDEX sysmaps_links_3 ON sysmaps_links (selementid2);
927CREATE TABLE sysmaps_link_triggers (
928	linktriggerid            number(20)                                NOT NULL,
929	linkid                   number(20)                                NOT NULL,
930	triggerid                number(20)                                NOT NULL,
931	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
932	color                    nvarchar2(6)    DEFAULT '000000'          ,
933	PRIMARY KEY (linktriggerid)
934);
935CREATE UNIQUE INDEX sysmaps_link_triggers_1 ON sysmaps_link_triggers (linkid,triggerid);
936CREATE INDEX sysmaps_link_triggers_2 ON sysmaps_link_triggers (triggerid);
937CREATE TABLE sysmap_element_url (
938	sysmapelementurlid       number(20)                                NOT NULL,
939	selementid               number(20)                                NOT NULL,
940	name                     nvarchar2(255)                            ,
941	url                      nvarchar2(255)  DEFAULT ''                ,
942	PRIMARY KEY (sysmapelementurlid)
943);
944CREATE UNIQUE INDEX sysmap_element_url_1 ON sysmap_element_url (selementid,name);
945CREATE TABLE sysmap_url (
946	sysmapurlid              number(20)                                NOT NULL,
947	sysmapid                 number(20)                                NOT NULL,
948	name                     nvarchar2(255)                            ,
949	url                      nvarchar2(255)  DEFAULT ''                ,
950	elementtype              number(10)      DEFAULT '0'               NOT NULL,
951	PRIMARY KEY (sysmapurlid)
952);
953CREATE UNIQUE INDEX sysmap_url_1 ON sysmap_url (sysmapid,name);
954CREATE TABLE sysmap_user (
955	sysmapuserid             number(20)                                NOT NULL,
956	sysmapid                 number(20)                                NOT NULL,
957	userid                   number(20)                                NOT NULL,
958	permission               number(10)      DEFAULT '2'               NOT NULL,
959	PRIMARY KEY (sysmapuserid)
960);
961CREATE UNIQUE INDEX sysmap_user_1 ON sysmap_user (sysmapid,userid);
962CREATE TABLE sysmap_usrgrp (
963	sysmapusrgrpid           number(20)                                NOT NULL,
964	sysmapid                 number(20)                                NOT NULL,
965	usrgrpid                 number(20)                                NOT NULL,
966	permission               number(10)      DEFAULT '2'               NOT NULL,
967	PRIMARY KEY (sysmapusrgrpid)
968);
969CREATE UNIQUE INDEX sysmap_usrgrp_1 ON sysmap_usrgrp (sysmapid,usrgrpid);
970CREATE TABLE maintenances_hosts (
971	maintenance_hostid       number(20)                                NOT NULL,
972	maintenanceid            number(20)                                NOT NULL,
973	hostid                   number(20)                                NOT NULL,
974	PRIMARY KEY (maintenance_hostid)
975);
976CREATE UNIQUE INDEX maintenances_hosts_1 ON maintenances_hosts (maintenanceid,hostid);
977CREATE INDEX maintenances_hosts_2 ON maintenances_hosts (hostid);
978CREATE TABLE maintenances_groups (
979	maintenance_groupid      number(20)                                NOT NULL,
980	maintenanceid            number(20)                                NOT NULL,
981	groupid                  number(20)                                NOT NULL,
982	PRIMARY KEY (maintenance_groupid)
983);
984CREATE UNIQUE INDEX maintenances_groups_1 ON maintenances_groups (maintenanceid,groupid);
985CREATE INDEX maintenances_groups_2 ON maintenances_groups (groupid);
986CREATE TABLE timeperiods (
987	timeperiodid             number(20)                                NOT NULL,
988	timeperiod_type          number(10)      DEFAULT '0'               NOT NULL,
989	every                    number(10)      DEFAULT '1'               NOT NULL,
990	month                    number(10)      DEFAULT '0'               NOT NULL,
991	dayofweek                number(10)      DEFAULT '0'               NOT NULL,
992	day                      number(10)      DEFAULT '0'               NOT NULL,
993	start_time               number(10)      DEFAULT '0'               NOT NULL,
994	period                   number(10)      DEFAULT '0'               NOT NULL,
995	start_date               number(10)      DEFAULT '0'               NOT NULL,
996	PRIMARY KEY (timeperiodid)
997);
998CREATE TABLE maintenances_windows (
999	maintenance_timeperiodid number(20)                                NOT NULL,
1000	maintenanceid            number(20)                                NOT NULL,
1001	timeperiodid             number(20)                                NOT NULL,
1002	PRIMARY KEY (maintenance_timeperiodid)
1003);
1004CREATE UNIQUE INDEX maintenances_windows_1 ON maintenances_windows (maintenanceid,timeperiodid);
1005CREATE INDEX maintenances_windows_2 ON maintenances_windows (timeperiodid);
1006CREATE TABLE regexps (
1007	regexpid                 number(20)                                NOT NULL,
1008	name                     nvarchar2(128)  DEFAULT ''                ,
1009	test_string              nvarchar2(2048) DEFAULT ''                ,
1010	PRIMARY KEY (regexpid)
1011);
1012CREATE UNIQUE INDEX regexps_1 ON regexps (name);
1013CREATE TABLE expressions (
1014	expressionid             number(20)                                NOT NULL,
1015	regexpid                 number(20)                                NOT NULL,
1016	expression               nvarchar2(255)  DEFAULT ''                ,
1017	expression_type          number(10)      DEFAULT '0'               NOT NULL,
1018	exp_delimiter            nvarchar2(1)    DEFAULT ''                ,
1019	case_sensitive           number(10)      DEFAULT '0'               NOT NULL,
1020	PRIMARY KEY (expressionid)
1021);
1022CREATE INDEX expressions_1 ON expressions (regexpid);
1023CREATE TABLE ids (
1024	table_name               nvarchar2(64)   DEFAULT ''                ,
1025	field_name               nvarchar2(64)   DEFAULT ''                ,
1026	nextid                   number(20)                                NOT NULL,
1027	PRIMARY KEY (table_name,field_name)
1028);
1029CREATE TABLE alerts (
1030	alertid                  number(20)                                NOT NULL,
1031	actionid                 number(20)                                NOT NULL,
1032	eventid                  number(20)                                NOT NULL,
1033	userid                   number(20)                                NULL,
1034	clock                    number(10)      DEFAULT '0'               NOT NULL,
1035	mediatypeid              number(20)                                NULL,
1036	sendto                   nvarchar2(1024) DEFAULT ''                ,
1037	subject                  nvarchar2(255)  DEFAULT ''                ,
1038	message                  nclob           DEFAULT ''                ,
1039	status                   number(10)      DEFAULT '0'               NOT NULL,
1040	retries                  number(10)      DEFAULT '0'               NOT NULL,
1041	error                    nvarchar2(2048) DEFAULT ''                ,
1042	esc_step                 number(10)      DEFAULT '0'               NOT NULL,
1043	alerttype                number(10)      DEFAULT '0'               NOT NULL,
1044	p_eventid                number(20)                                NULL,
1045	acknowledgeid            number(20)                                NULL,
1046	PRIMARY KEY (alertid)
1047);
1048CREATE INDEX alerts_1 ON alerts (actionid);
1049CREATE INDEX alerts_2 ON alerts (clock);
1050CREATE INDEX alerts_3 ON alerts (eventid);
1051CREATE INDEX alerts_4 ON alerts (status);
1052CREATE INDEX alerts_5 ON alerts (mediatypeid);
1053CREATE INDEX alerts_6 ON alerts (userid);
1054CREATE INDEX alerts_7 ON alerts (p_eventid);
1055CREATE TABLE history (
1056	itemid                   number(20)                                NOT NULL,
1057	clock                    number(10)      DEFAULT '0'               NOT NULL,
1058	value                    number(20,4)    DEFAULT '0.0000'          NOT NULL,
1059	ns                       number(10)      DEFAULT '0'               NOT NULL
1060);
1061CREATE INDEX history_1 ON history (itemid,clock);
1062CREATE TABLE history_uint (
1063	itemid                   number(20)                                NOT NULL,
1064	clock                    number(10)      DEFAULT '0'               NOT NULL,
1065	value                    number(20)      DEFAULT '0'               NOT NULL,
1066	ns                       number(10)      DEFAULT '0'               NOT NULL
1067);
1068CREATE INDEX history_uint_1 ON history_uint (itemid,clock);
1069CREATE TABLE history_str (
1070	itemid                   number(20)                                NOT NULL,
1071	clock                    number(10)      DEFAULT '0'               NOT NULL,
1072	value                    nvarchar2(255)  DEFAULT ''                ,
1073	ns                       number(10)      DEFAULT '0'               NOT NULL
1074);
1075CREATE INDEX history_str_1 ON history_str (itemid,clock);
1076CREATE TABLE history_log (
1077	itemid                   number(20)                                NOT NULL,
1078	clock                    number(10)      DEFAULT '0'               NOT NULL,
1079	timestamp                number(10)      DEFAULT '0'               NOT NULL,
1080	source                   nvarchar2(64)   DEFAULT ''                ,
1081	severity                 number(10)      DEFAULT '0'               NOT NULL,
1082	value                    nclob           DEFAULT ''                ,
1083	logeventid               number(10)      DEFAULT '0'               NOT NULL,
1084	ns                       number(10)      DEFAULT '0'               NOT NULL
1085);
1086CREATE INDEX history_log_1 ON history_log (itemid,clock);
1087CREATE TABLE history_text (
1088	itemid                   number(20)                                NOT NULL,
1089	clock                    number(10)      DEFAULT '0'               NOT NULL,
1090	value                    nclob           DEFAULT ''                ,
1091	ns                       number(10)      DEFAULT '0'               NOT NULL
1092);
1093CREATE INDEX history_text_1 ON history_text (itemid,clock);
1094CREATE TABLE proxy_history (
1095	id                       number(20)                                NOT NULL,
1096	itemid                   number(20)                                NOT NULL,
1097	clock                    number(10)      DEFAULT '0'               NOT NULL,
1098	timestamp                number(10)      DEFAULT '0'               NOT NULL,
1099	source                   nvarchar2(64)   DEFAULT ''                ,
1100	severity                 number(10)      DEFAULT '0'               NOT NULL,
1101	value                    nclob           DEFAULT ''                ,
1102	logeventid               number(10)      DEFAULT '0'               NOT NULL,
1103	ns                       number(10)      DEFAULT '0'               NOT NULL,
1104	state                    number(10)      DEFAULT '0'               NOT NULL,
1105	lastlogsize              number(20)      DEFAULT '0'               NOT NULL,
1106	mtime                    number(10)      DEFAULT '0'               NOT NULL,
1107	flags                    number(10)      DEFAULT '0'               NOT NULL,
1108	PRIMARY KEY (id)
1109);
1110CREATE INDEX proxy_history_1 ON proxy_history (clock);
1111CREATE TABLE proxy_dhistory (
1112	id                       number(20)                                NOT NULL,
1113	clock                    number(10)      DEFAULT '0'               NOT NULL,
1114	druleid                  number(20)                                NOT NULL,
1115	ip                       nvarchar2(39)   DEFAULT ''                ,
1116	port                     number(10)      DEFAULT '0'               NOT NULL,
1117	value                    nvarchar2(255)  DEFAULT ''                ,
1118	status                   number(10)      DEFAULT '0'               NOT NULL,
1119	dcheckid                 number(20)                                NULL,
1120	dns                      nvarchar2(255)  DEFAULT ''                ,
1121	PRIMARY KEY (id)
1122);
1123CREATE INDEX proxy_dhistory_1 ON proxy_dhistory (clock);
1124CREATE TABLE events (
1125	eventid                  number(20)                                NOT NULL,
1126	source                   number(10)      DEFAULT '0'               NOT NULL,
1127	object                   number(10)      DEFAULT '0'               NOT NULL,
1128	objectid                 number(20)      DEFAULT '0'               NOT NULL,
1129	clock                    number(10)      DEFAULT '0'               NOT NULL,
1130	value                    number(10)      DEFAULT '0'               NOT NULL,
1131	acknowledged             number(10)      DEFAULT '0'               NOT NULL,
1132	ns                       number(10)      DEFAULT '0'               NOT NULL,
1133	name                     nvarchar2(2048) DEFAULT ''                ,
1134	severity                 number(10)      DEFAULT '0'               NOT NULL,
1135	PRIMARY KEY (eventid)
1136);
1137CREATE INDEX events_1 ON events (source,object,objectid,clock);
1138CREATE INDEX events_2 ON events (source,object,clock);
1139CREATE TABLE trends (
1140	itemid                   number(20)                                NOT NULL,
1141	clock                    number(10)      DEFAULT '0'               NOT NULL,
1142	num                      number(10)      DEFAULT '0'               NOT NULL,
1143	value_min                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1144	value_avg                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1145	value_max                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1146	PRIMARY KEY (itemid,clock)
1147);
1148CREATE TABLE trends_uint (
1149	itemid                   number(20)                                NOT NULL,
1150	clock                    number(10)      DEFAULT '0'               NOT NULL,
1151	num                      number(10)      DEFAULT '0'               NOT NULL,
1152	value_min                number(20)      DEFAULT '0'               NOT NULL,
1153	value_avg                number(20)      DEFAULT '0'               NOT NULL,
1154	value_max                number(20)      DEFAULT '0'               NOT NULL,
1155	PRIMARY KEY (itemid,clock)
1156);
1157CREATE TABLE acknowledges (
1158	acknowledgeid            number(20)                                NOT NULL,
1159	userid                   number(20)                                NOT NULL,
1160	eventid                  number(20)                                NOT NULL,
1161	clock                    number(10)      DEFAULT '0'               NOT NULL,
1162	message                  nvarchar2(255)  DEFAULT ''                ,
1163	action                   number(10)      DEFAULT '0'               NOT NULL,
1164	old_severity             number(10)      DEFAULT '0'               NOT NULL,
1165	new_severity             number(10)      DEFAULT '0'               NOT NULL,
1166	PRIMARY KEY (acknowledgeid)
1167);
1168CREATE INDEX acknowledges_1 ON acknowledges (userid);
1169CREATE INDEX acknowledges_2 ON acknowledges (eventid);
1170CREATE INDEX acknowledges_3 ON acknowledges (clock);
1171CREATE TABLE auditlog (
1172	auditid                  number(20)                                NOT NULL,
1173	userid                   number(20)                                NOT NULL,
1174	clock                    number(10)      DEFAULT '0'               NOT NULL,
1175	action                   number(10)      DEFAULT '0'               NOT NULL,
1176	resourcetype             number(10)      DEFAULT '0'               NOT NULL,
1177	details                  nvarchar2(128)  DEFAULT '0'               ,
1178	ip                       nvarchar2(39)   DEFAULT ''                ,
1179	resourceid               number(20)      DEFAULT '0'               NOT NULL,
1180	resourcename             nvarchar2(255)  DEFAULT ''                ,
1181	PRIMARY KEY (auditid)
1182);
1183CREATE INDEX auditlog_1 ON auditlog (userid,clock);
1184CREATE INDEX auditlog_2 ON auditlog (clock);
1185CREATE TABLE auditlog_details (
1186	auditdetailid            number(20)                                NOT NULL,
1187	auditid                  number(20)                                NOT NULL,
1188	table_name               nvarchar2(64)   DEFAULT ''                ,
1189	field_name               nvarchar2(64)   DEFAULT ''                ,
1190	oldvalue                 nvarchar2(2048) DEFAULT ''                ,
1191	newvalue                 nvarchar2(2048) DEFAULT ''                ,
1192	PRIMARY KEY (auditdetailid)
1193);
1194CREATE INDEX auditlog_details_1 ON auditlog_details (auditid);
1195CREATE TABLE service_alarms (
1196	servicealarmid           number(20)                                NOT NULL,
1197	serviceid                number(20)                                NOT NULL,
1198	clock                    number(10)      DEFAULT '0'               NOT NULL,
1199	value                    number(10)      DEFAULT '0'               NOT NULL,
1200	PRIMARY KEY (servicealarmid)
1201);
1202CREATE INDEX service_alarms_1 ON service_alarms (serviceid,clock);
1203CREATE INDEX service_alarms_2 ON service_alarms (clock);
1204CREATE TABLE autoreg_host (
1205	autoreg_hostid           number(20)                                NOT NULL,
1206	proxy_hostid             number(20)                                NULL,
1207	host                     nvarchar2(64)   DEFAULT ''                ,
1208	listen_ip                nvarchar2(39)   DEFAULT ''                ,
1209	listen_port              number(10)      DEFAULT '0'               NOT NULL,
1210	listen_dns               nvarchar2(255)  DEFAULT ''                ,
1211	host_metadata            nvarchar2(255)  DEFAULT ''                ,
1212	PRIMARY KEY (autoreg_hostid)
1213);
1214CREATE INDEX autoreg_host_1 ON autoreg_host (host);
1215CREATE INDEX autoreg_host_2 ON autoreg_host (proxy_hostid);
1216CREATE TABLE proxy_autoreg_host (
1217	id                       number(20)                                NOT NULL,
1218	clock                    number(10)      DEFAULT '0'               NOT NULL,
1219	host                     nvarchar2(64)   DEFAULT ''                ,
1220	listen_ip                nvarchar2(39)   DEFAULT ''                ,
1221	listen_port              number(10)      DEFAULT '0'               NOT NULL,
1222	listen_dns               nvarchar2(255)  DEFAULT ''                ,
1223	host_metadata            nvarchar2(255)  DEFAULT ''                ,
1224	PRIMARY KEY (id)
1225);
1226CREATE INDEX proxy_autoreg_host_1 ON proxy_autoreg_host (clock);
1227CREATE TABLE dhosts (
1228	dhostid                  number(20)                                NOT NULL,
1229	druleid                  number(20)                                NOT NULL,
1230	status                   number(10)      DEFAULT '0'               NOT NULL,
1231	lastup                   number(10)      DEFAULT '0'               NOT NULL,
1232	lastdown                 number(10)      DEFAULT '0'               NOT NULL,
1233	PRIMARY KEY (dhostid)
1234);
1235CREATE INDEX dhosts_1 ON dhosts (druleid);
1236CREATE TABLE dservices (
1237	dserviceid               number(20)                                NOT NULL,
1238	dhostid                  number(20)                                NOT NULL,
1239	value                    nvarchar2(255)  DEFAULT ''                ,
1240	port                     number(10)      DEFAULT '0'               NOT NULL,
1241	status                   number(10)      DEFAULT '0'               NOT NULL,
1242	lastup                   number(10)      DEFAULT '0'               NOT NULL,
1243	lastdown                 number(10)      DEFAULT '0'               NOT NULL,
1244	dcheckid                 number(20)                                NOT NULL,
1245	ip                       nvarchar2(39)   DEFAULT ''                ,
1246	dns                      nvarchar2(255)  DEFAULT ''                ,
1247	PRIMARY KEY (dserviceid)
1248);
1249CREATE UNIQUE INDEX dservices_1 ON dservices (dcheckid,ip,port);
1250CREATE INDEX dservices_2 ON dservices (dhostid);
1251CREATE TABLE escalations (
1252	escalationid             number(20)                                NOT NULL,
1253	actionid                 number(20)                                NOT NULL,
1254	triggerid                number(20)                                NULL,
1255	eventid                  number(20)                                NULL,
1256	r_eventid                number(20)                                NULL,
1257	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
1258	esc_step                 number(10)      DEFAULT '0'               NOT NULL,
1259	status                   number(10)      DEFAULT '0'               NOT NULL,
1260	itemid                   number(20)                                NULL,
1261	acknowledgeid            number(20)                                NULL,
1262	PRIMARY KEY (escalationid)
1263);
1264CREATE UNIQUE INDEX escalations_1 ON escalations (triggerid,itemid,escalationid);
1265CREATE INDEX escalations_2 ON escalations (eventid);
1266CREATE INDEX escalations_3 ON escalations (nextcheck);
1267CREATE TABLE globalvars (
1268	globalvarid              number(20)                                NOT NULL,
1269	snmp_lastsize            number(20)      DEFAULT '0'               NOT NULL,
1270	PRIMARY KEY (globalvarid)
1271);
1272CREATE TABLE graph_discovery (
1273	graphid                  number(20)                                NOT NULL,
1274	parent_graphid           number(20)                                NOT NULL,
1275	PRIMARY KEY (graphid)
1276);
1277CREATE INDEX graph_discovery_1 ON graph_discovery (parent_graphid);
1278CREATE TABLE host_inventory (
1279	hostid                   number(20)                                NOT NULL,
1280	inventory_mode           number(10)      DEFAULT '0'               NOT NULL,
1281	type                     nvarchar2(64)   DEFAULT ''                ,
1282	type_full                nvarchar2(64)   DEFAULT ''                ,
1283	name                     nvarchar2(64)   DEFAULT ''                ,
1284	alias                    nvarchar2(64)   DEFAULT ''                ,
1285	os                       nvarchar2(64)   DEFAULT ''                ,
1286	os_full                  nvarchar2(255)  DEFAULT ''                ,
1287	os_short                 nvarchar2(64)   DEFAULT ''                ,
1288	serialno_a               nvarchar2(64)   DEFAULT ''                ,
1289	serialno_b               nvarchar2(64)   DEFAULT ''                ,
1290	tag                      nvarchar2(64)   DEFAULT ''                ,
1291	asset_tag                nvarchar2(64)   DEFAULT ''                ,
1292	macaddress_a             nvarchar2(64)   DEFAULT ''                ,
1293	macaddress_b             nvarchar2(64)   DEFAULT ''                ,
1294	hardware                 nvarchar2(255)  DEFAULT ''                ,
1295	hardware_full            nvarchar2(2048) DEFAULT ''                ,
1296	software                 nvarchar2(255)  DEFAULT ''                ,
1297	software_full            nvarchar2(2048) DEFAULT ''                ,
1298	software_app_a           nvarchar2(64)   DEFAULT ''                ,
1299	software_app_b           nvarchar2(64)   DEFAULT ''                ,
1300	software_app_c           nvarchar2(64)   DEFAULT ''                ,
1301	software_app_d           nvarchar2(64)   DEFAULT ''                ,
1302	software_app_e           nvarchar2(64)   DEFAULT ''                ,
1303	contact                  nvarchar2(2048) DEFAULT ''                ,
1304	location                 nvarchar2(2048) DEFAULT ''                ,
1305	location_lat             nvarchar2(16)   DEFAULT ''                ,
1306	location_lon             nvarchar2(16)   DEFAULT ''                ,
1307	notes                    nvarchar2(2048) DEFAULT ''                ,
1308	chassis                  nvarchar2(64)   DEFAULT ''                ,
1309	model                    nvarchar2(64)   DEFAULT ''                ,
1310	hw_arch                  nvarchar2(32)   DEFAULT ''                ,
1311	vendor                   nvarchar2(64)   DEFAULT ''                ,
1312	contract_number          nvarchar2(64)   DEFAULT ''                ,
1313	installer_name           nvarchar2(64)   DEFAULT ''                ,
1314	deployment_status        nvarchar2(64)   DEFAULT ''                ,
1315	url_a                    nvarchar2(255)  DEFAULT ''                ,
1316	url_b                    nvarchar2(255)  DEFAULT ''                ,
1317	url_c                    nvarchar2(255)  DEFAULT ''                ,
1318	host_networks            nvarchar2(2048) DEFAULT ''                ,
1319	host_netmask             nvarchar2(39)   DEFAULT ''                ,
1320	host_router              nvarchar2(39)   DEFAULT ''                ,
1321	oob_ip                   nvarchar2(39)   DEFAULT ''                ,
1322	oob_netmask              nvarchar2(39)   DEFAULT ''                ,
1323	oob_router               nvarchar2(39)   DEFAULT ''                ,
1324	date_hw_purchase         nvarchar2(64)   DEFAULT ''                ,
1325	date_hw_install          nvarchar2(64)   DEFAULT ''                ,
1326	date_hw_expiry           nvarchar2(64)   DEFAULT ''                ,
1327	date_hw_decomm           nvarchar2(64)   DEFAULT ''                ,
1328	site_address_a           nvarchar2(128)  DEFAULT ''                ,
1329	site_address_b           nvarchar2(128)  DEFAULT ''                ,
1330	site_address_c           nvarchar2(128)  DEFAULT ''                ,
1331	site_city                nvarchar2(128)  DEFAULT ''                ,
1332	site_state               nvarchar2(64)   DEFAULT ''                ,
1333	site_country             nvarchar2(64)   DEFAULT ''                ,
1334	site_zip                 nvarchar2(64)   DEFAULT ''                ,
1335	site_rack                nvarchar2(128)  DEFAULT ''                ,
1336	site_notes               nvarchar2(2048) DEFAULT ''                ,
1337	poc_1_name               nvarchar2(128)  DEFAULT ''                ,
1338	poc_1_email              nvarchar2(128)  DEFAULT ''                ,
1339	poc_1_phone_a            nvarchar2(64)   DEFAULT ''                ,
1340	poc_1_phone_b            nvarchar2(64)   DEFAULT ''                ,
1341	poc_1_cell               nvarchar2(64)   DEFAULT ''                ,
1342	poc_1_screen             nvarchar2(64)   DEFAULT ''                ,
1343	poc_1_notes              nvarchar2(2048) DEFAULT ''                ,
1344	poc_2_name               nvarchar2(128)  DEFAULT ''                ,
1345	poc_2_email              nvarchar2(128)  DEFAULT ''                ,
1346	poc_2_phone_a            nvarchar2(64)   DEFAULT ''                ,
1347	poc_2_phone_b            nvarchar2(64)   DEFAULT ''                ,
1348	poc_2_cell               nvarchar2(64)   DEFAULT ''                ,
1349	poc_2_screen             nvarchar2(64)   DEFAULT ''                ,
1350	poc_2_notes              nvarchar2(2048) DEFAULT ''                ,
1351	PRIMARY KEY (hostid)
1352);
1353CREATE TABLE housekeeper (
1354	housekeeperid            number(20)                                NOT NULL,
1355	tablename                nvarchar2(64)   DEFAULT ''                ,
1356	field                    nvarchar2(64)   DEFAULT ''                ,
1357	value                    number(20)                                NOT NULL,
1358	PRIMARY KEY (housekeeperid)
1359);
1360CREATE TABLE images (
1361	imageid                  number(20)                                NOT NULL,
1362	imagetype                number(10)      DEFAULT '0'               NOT NULL,
1363	name                     nvarchar2(64)   DEFAULT '0'               ,
1364	image                    blob            DEFAULT ''                NOT NULL,
1365	PRIMARY KEY (imageid)
1366);
1367CREATE UNIQUE INDEX images_1 ON images (name);
1368CREATE TABLE item_discovery (
1369	itemdiscoveryid          number(20)                                NOT NULL,
1370	itemid                   number(20)                                NOT NULL,
1371	parent_itemid            number(20)                                NOT NULL,
1372	key_                     nvarchar2(255)  DEFAULT ''                ,
1373	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1374	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1375	PRIMARY KEY (itemdiscoveryid)
1376);
1377CREATE UNIQUE INDEX item_discovery_1 ON item_discovery (itemid,parent_itemid);
1378CREATE INDEX item_discovery_2 ON item_discovery (parent_itemid);
1379CREATE TABLE host_discovery (
1380	hostid                   number(20)                                NOT NULL,
1381	parent_hostid            number(20)                                NULL,
1382	parent_itemid            number(20)                                NULL,
1383	host                     nvarchar2(64)   DEFAULT ''                ,
1384	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1385	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1386	PRIMARY KEY (hostid)
1387);
1388CREATE TABLE interface_discovery (
1389	interfaceid              number(20)                                NOT NULL,
1390	parent_interfaceid       number(20)                                NOT NULL,
1391	PRIMARY KEY (interfaceid)
1392);
1393CREATE TABLE profiles (
1394	profileid                number(20)                                NOT NULL,
1395	userid                   number(20)                                NOT NULL,
1396	idx                      nvarchar2(96)   DEFAULT ''                ,
1397	idx2                     number(20)      DEFAULT '0'               NOT NULL,
1398	value_id                 number(20)      DEFAULT '0'               NOT NULL,
1399	value_int                number(10)      DEFAULT '0'               NOT NULL,
1400	value_str                nvarchar2(255)  DEFAULT ''                ,
1401	source                   nvarchar2(96)   DEFAULT ''                ,
1402	type                     number(10)      DEFAULT '0'               NOT NULL,
1403	PRIMARY KEY (profileid)
1404);
1405CREATE INDEX profiles_1 ON profiles (userid,idx,idx2);
1406CREATE INDEX profiles_2 ON profiles (userid,profileid);
1407CREATE TABLE sessions (
1408	sessionid                nvarchar2(32)   DEFAULT ''                ,
1409	userid                   number(20)                                NOT NULL,
1410	lastaccess               number(10)      DEFAULT '0'               NOT NULL,
1411	status                   number(10)      DEFAULT '0'               NOT NULL,
1412	PRIMARY KEY (sessionid)
1413);
1414CREATE INDEX sessions_1 ON sessions (userid,status,lastaccess);
1415CREATE TABLE trigger_discovery (
1416	triggerid                number(20)                                NOT NULL,
1417	parent_triggerid         number(20)                                NOT NULL,
1418	PRIMARY KEY (triggerid)
1419);
1420CREATE INDEX trigger_discovery_1 ON trigger_discovery (parent_triggerid);
1421CREATE TABLE application_template (
1422	application_templateid   number(20)                                NOT NULL,
1423	applicationid            number(20)                                NOT NULL,
1424	templateid               number(20)                                NOT NULL,
1425	PRIMARY KEY (application_templateid)
1426);
1427CREATE UNIQUE INDEX application_template_1 ON application_template (applicationid,templateid);
1428CREATE INDEX application_template_2 ON application_template (templateid);
1429CREATE TABLE item_condition (
1430	item_conditionid         number(20)                                NOT NULL,
1431	itemid                   number(20)                                NOT NULL,
1432	operator                 number(10)      DEFAULT '8'               NOT NULL,
1433	macro                    nvarchar2(64)   DEFAULT ''                ,
1434	value                    nvarchar2(255)  DEFAULT ''                ,
1435	PRIMARY KEY (item_conditionid)
1436);
1437CREATE INDEX item_condition_1 ON item_condition (itemid);
1438CREATE TABLE application_prototype (
1439	application_prototypeid  number(20)                                NOT NULL,
1440	itemid                   number(20)                                NOT NULL,
1441	templateid               number(20)                                NULL,
1442	name                     nvarchar2(255)  DEFAULT ''                ,
1443	PRIMARY KEY (application_prototypeid)
1444);
1445CREATE INDEX application_prototype_1 ON application_prototype (itemid);
1446CREATE INDEX application_prototype_2 ON application_prototype (templateid);
1447CREATE TABLE item_application_prototype (
1448	item_application_prototypeid number(20)                                NOT NULL,
1449	application_prototypeid  number(20)                                NOT NULL,
1450	itemid                   number(20)                                NOT NULL,
1451	PRIMARY KEY (item_application_prototypeid)
1452);
1453CREATE UNIQUE INDEX item_application_prototype_1 ON item_application_prototype (application_prototypeid,itemid);
1454CREATE INDEX item_application_prototype_2 ON item_application_prototype (itemid);
1455CREATE TABLE application_discovery (
1456	application_discoveryid  number(20)                                NOT NULL,
1457	applicationid            number(20)                                NOT NULL,
1458	application_prototypeid  number(20)                                NOT NULL,
1459	name                     nvarchar2(255)  DEFAULT ''                ,
1460	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1461	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1462	PRIMARY KEY (application_discoveryid)
1463);
1464CREATE INDEX application_discovery_1 ON application_discovery (applicationid);
1465CREATE INDEX application_discovery_2 ON application_discovery (application_prototypeid);
1466CREATE TABLE opinventory (
1467	operationid              number(20)                                NOT NULL,
1468	inventory_mode           number(10)      DEFAULT '0'               NOT NULL,
1469	PRIMARY KEY (operationid)
1470);
1471CREATE TABLE trigger_tag (
1472	triggertagid             number(20)                                NOT NULL,
1473	triggerid                number(20)                                NOT NULL,
1474	tag                      nvarchar2(255)  DEFAULT ''                ,
1475	value                    nvarchar2(255)  DEFAULT ''                ,
1476	PRIMARY KEY (triggertagid)
1477);
1478CREATE INDEX trigger_tag_1 ON trigger_tag (triggerid);
1479CREATE TABLE event_tag (
1480	eventtagid               number(20)                                NOT NULL,
1481	eventid                  number(20)                                NOT NULL,
1482	tag                      nvarchar2(255)  DEFAULT ''                ,
1483	value                    nvarchar2(255)  DEFAULT ''                ,
1484	PRIMARY KEY (eventtagid)
1485);
1486CREATE INDEX event_tag_1 ON event_tag (eventid);
1487CREATE TABLE problem (
1488	eventid                  number(20)                                NOT NULL,
1489	source                   number(10)      DEFAULT '0'               NOT NULL,
1490	object                   number(10)      DEFAULT '0'               NOT NULL,
1491	objectid                 number(20)      DEFAULT '0'               NOT NULL,
1492	clock                    number(10)      DEFAULT '0'               NOT NULL,
1493	ns                       number(10)      DEFAULT '0'               NOT NULL,
1494	r_eventid                number(20)                                NULL,
1495	r_clock                  number(10)      DEFAULT '0'               NOT NULL,
1496	r_ns                     number(10)      DEFAULT '0'               NOT NULL,
1497	correlationid            number(20)                                NULL,
1498	userid                   number(20)                                NULL,
1499	name                     nvarchar2(2048) DEFAULT ''                ,
1500	acknowledged             number(10)      DEFAULT '0'               NOT NULL,
1501	severity                 number(10)      DEFAULT '0'               NOT NULL,
1502	PRIMARY KEY (eventid)
1503);
1504CREATE INDEX problem_1 ON problem (source,object,objectid);
1505CREATE INDEX problem_2 ON problem (r_clock);
1506CREATE INDEX problem_3 ON problem (r_eventid);
1507CREATE TABLE problem_tag (
1508	problemtagid             number(20)                                NOT NULL,
1509	eventid                  number(20)                                NOT NULL,
1510	tag                      nvarchar2(255)  DEFAULT ''                ,
1511	value                    nvarchar2(255)  DEFAULT ''                ,
1512	PRIMARY KEY (problemtagid)
1513);
1514CREATE INDEX problem_tag_1 ON problem_tag (eventid,tag,value);
1515CREATE TABLE tag_filter (
1516	tag_filterid             number(20)                                NOT NULL,
1517	usrgrpid                 number(20)                                NOT NULL,
1518	groupid                  number(20)                                NOT NULL,
1519	tag                      nvarchar2(255)  DEFAULT ''                ,
1520	value                    nvarchar2(255)  DEFAULT ''                ,
1521	PRIMARY KEY (tag_filterid)
1522);
1523CREATE TABLE event_recovery (
1524	eventid                  number(20)                                NOT NULL,
1525	r_eventid                number(20)                                NOT NULL,
1526	c_eventid                number(20)                                NULL,
1527	correlationid            number(20)                                NULL,
1528	userid                   number(20)                                NULL,
1529	PRIMARY KEY (eventid)
1530);
1531CREATE INDEX event_recovery_1 ON event_recovery (r_eventid);
1532CREATE INDEX event_recovery_2 ON event_recovery (c_eventid);
1533CREATE TABLE correlation (
1534	correlationid            number(20)                                NOT NULL,
1535	name                     nvarchar2(255)  DEFAULT ''                ,
1536	description              nvarchar2(2048) DEFAULT ''                ,
1537	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
1538	status                   number(10)      DEFAULT '0'               NOT NULL,
1539	formula                  nvarchar2(255)  DEFAULT ''                ,
1540	PRIMARY KEY (correlationid)
1541);
1542CREATE INDEX correlation_1 ON correlation (status);
1543CREATE UNIQUE INDEX correlation_2 ON correlation (name);
1544CREATE TABLE corr_condition (
1545	corr_conditionid         number(20)                                NOT NULL,
1546	correlationid            number(20)                                NOT NULL,
1547	type                     number(10)      DEFAULT '0'               NOT NULL,
1548	PRIMARY KEY (corr_conditionid)
1549);
1550CREATE INDEX corr_condition_1 ON corr_condition (correlationid);
1551CREATE TABLE corr_condition_tag (
1552	corr_conditionid         number(20)                                NOT NULL,
1553	tag                      nvarchar2(255)  DEFAULT ''                ,
1554	PRIMARY KEY (corr_conditionid)
1555);
1556CREATE TABLE corr_condition_group (
1557	corr_conditionid         number(20)                                NOT NULL,
1558	operator                 number(10)      DEFAULT '0'               NOT NULL,
1559	groupid                  number(20)                                NOT NULL,
1560	PRIMARY KEY (corr_conditionid)
1561);
1562CREATE INDEX corr_condition_group_1 ON corr_condition_group (groupid);
1563CREATE TABLE corr_condition_tagpair (
1564	corr_conditionid         number(20)                                NOT NULL,
1565	oldtag                   nvarchar2(255)  DEFAULT ''                ,
1566	newtag                   nvarchar2(255)  DEFAULT ''                ,
1567	PRIMARY KEY (corr_conditionid)
1568);
1569CREATE TABLE corr_condition_tagvalue (
1570	corr_conditionid         number(20)                                NOT NULL,
1571	tag                      nvarchar2(255)  DEFAULT ''                ,
1572	operator                 number(10)      DEFAULT '0'               NOT NULL,
1573	value                    nvarchar2(255)  DEFAULT ''                ,
1574	PRIMARY KEY (corr_conditionid)
1575);
1576CREATE TABLE corr_operation (
1577	corr_operationid         number(20)                                NOT NULL,
1578	correlationid            number(20)                                NOT NULL,
1579	type                     number(10)      DEFAULT '0'               NOT NULL,
1580	PRIMARY KEY (corr_operationid)
1581);
1582CREATE INDEX corr_operation_1 ON corr_operation (correlationid);
1583CREATE TABLE task (
1584	taskid                   number(20)                                NOT NULL,
1585	type                     number(10)                                NOT NULL,
1586	status                   number(10)      DEFAULT '0'               NOT NULL,
1587	clock                    number(10)      DEFAULT '0'               NOT NULL,
1588	ttl                      number(10)      DEFAULT '0'               NOT NULL,
1589	proxy_hostid             number(20)                                NULL,
1590	PRIMARY KEY (taskid)
1591);
1592CREATE INDEX task_1 ON task (status,proxy_hostid);
1593CREATE TABLE task_close_problem (
1594	taskid                   number(20)                                NOT NULL,
1595	acknowledgeid            number(20)                                NOT NULL,
1596	PRIMARY KEY (taskid)
1597);
1598CREATE TABLE item_preproc (
1599	item_preprocid           number(20)                                NOT NULL,
1600	itemid                   number(20)                                NOT NULL,
1601	step                     number(10)      DEFAULT '0'               NOT NULL,
1602	type                     number(10)      DEFAULT '0'               NOT NULL,
1603	params                   nvarchar2(255)  DEFAULT ''                ,
1604	PRIMARY KEY (item_preprocid)
1605);
1606CREATE INDEX item_preproc_1 ON item_preproc (itemid,step);
1607CREATE TABLE task_remote_command (
1608	taskid                   number(20)                                NOT NULL,
1609	command_type             number(10)      DEFAULT '0'               NOT NULL,
1610	execute_on               number(10)      DEFAULT '0'               NOT NULL,
1611	port                     number(10)      DEFAULT '0'               NOT NULL,
1612	authtype                 number(10)      DEFAULT '0'               NOT NULL,
1613	username                 nvarchar2(64)   DEFAULT ''                ,
1614	password                 nvarchar2(64)   DEFAULT ''                ,
1615	publickey                nvarchar2(64)   DEFAULT ''                ,
1616	privatekey               nvarchar2(64)   DEFAULT ''                ,
1617	command                  nvarchar2(2048) DEFAULT ''                ,
1618	alertid                  number(20)                                NULL,
1619	parent_taskid            number(20)                                NOT NULL,
1620	hostid                   number(20)                                NOT NULL,
1621	PRIMARY KEY (taskid)
1622);
1623CREATE TABLE task_remote_command_result (
1624	taskid                   number(20)                                NOT NULL,
1625	status                   number(10)      DEFAULT '0'               NOT NULL,
1626	parent_taskid            number(20)                                NOT NULL,
1627	info                     nvarchar2(2048) DEFAULT ''                ,
1628	PRIMARY KEY (taskid)
1629);
1630CREATE TABLE task_acknowledge (
1631	taskid                   number(20)                                NOT NULL,
1632	acknowledgeid            number(20)                                NOT NULL,
1633	PRIMARY KEY (taskid)
1634);
1635CREATE TABLE sysmap_shape (
1636	sysmap_shapeid           number(20)                                NOT NULL,
1637	sysmapid                 number(20)                                NOT NULL,
1638	type                     number(10)      DEFAULT '0'               NOT NULL,
1639	x                        number(10)      DEFAULT '0'               NOT NULL,
1640	y                        number(10)      DEFAULT '0'               NOT NULL,
1641	width                    number(10)      DEFAULT '200'             NOT NULL,
1642	height                   number(10)      DEFAULT '200'             NOT NULL,
1643	text                     nvarchar2(2048) DEFAULT ''                ,
1644	font                     number(10)      DEFAULT '9'               NOT NULL,
1645	font_size                number(10)      DEFAULT '11'              NOT NULL,
1646	font_color               nvarchar2(6)    DEFAULT '000000'          ,
1647	text_halign              number(10)      DEFAULT '0'               NOT NULL,
1648	text_valign              number(10)      DEFAULT '0'               NOT NULL,
1649	border_type              number(10)      DEFAULT '0'               NOT NULL,
1650	border_width             number(10)      DEFAULT '1'               NOT NULL,
1651	border_color             nvarchar2(6)    DEFAULT '000000'          ,
1652	background_color         nvarchar2(6)    DEFAULT ''                ,
1653	zindex                   number(10)      DEFAULT '0'               NOT NULL,
1654	PRIMARY KEY (sysmap_shapeid)
1655);
1656CREATE INDEX sysmap_shape_1 ON sysmap_shape (sysmapid);
1657CREATE TABLE sysmap_element_trigger (
1658	selement_triggerid       number(20)                                NOT NULL,
1659	selementid               number(20)                                NOT NULL,
1660	triggerid                number(20)                                NOT NULL,
1661	PRIMARY KEY (selement_triggerid)
1662);
1663CREATE UNIQUE INDEX sysmap_element_trigger_1 ON sysmap_element_trigger (selementid,triggerid);
1664CREATE TABLE httptest_field (
1665	httptest_fieldid         number(20)                                NOT NULL,
1666	httptestid               number(20)                                NOT NULL,
1667	type                     number(10)      DEFAULT '0'               NOT NULL,
1668	name                     nvarchar2(255)  DEFAULT ''                ,
1669	value                    nvarchar2(2048) DEFAULT ''                ,
1670	PRIMARY KEY (httptest_fieldid)
1671);
1672CREATE INDEX httptest_field_1 ON httptest_field (httptestid);
1673CREATE TABLE httpstep_field (
1674	httpstep_fieldid         number(20)                                NOT NULL,
1675	httpstepid               number(20)                                NOT NULL,
1676	type                     number(10)      DEFAULT '0'               NOT NULL,
1677	name                     nvarchar2(255)  DEFAULT ''                ,
1678	value                    nvarchar2(2048) DEFAULT ''                ,
1679	PRIMARY KEY (httpstep_fieldid)
1680);
1681CREATE INDEX httpstep_field_1 ON httpstep_field (httpstepid);
1682CREATE TABLE dashboard (
1683	dashboardid              number(20)                                NOT NULL,
1684	name                     nvarchar2(255)                            ,
1685	userid                   number(20)                                NOT NULL,
1686	private                  number(10)      DEFAULT '1'               NOT NULL,
1687	PRIMARY KEY (dashboardid)
1688);
1689CREATE TABLE dashboard_user (
1690	dashboard_userid         number(20)                                NOT NULL,
1691	dashboardid              number(20)                                NOT NULL,
1692	userid                   number(20)                                NOT NULL,
1693	permission               number(10)      DEFAULT '2'               NOT NULL,
1694	PRIMARY KEY (dashboard_userid)
1695);
1696CREATE UNIQUE INDEX dashboard_user_1 ON dashboard_user (dashboardid,userid);
1697CREATE TABLE dashboard_usrgrp (
1698	dashboard_usrgrpid       number(20)                                NOT NULL,
1699	dashboardid              number(20)                                NOT NULL,
1700	usrgrpid                 number(20)                                NOT NULL,
1701	permission               number(10)      DEFAULT '2'               NOT NULL,
1702	PRIMARY KEY (dashboard_usrgrpid)
1703);
1704CREATE UNIQUE INDEX dashboard_usrgrp_1 ON dashboard_usrgrp (dashboardid,usrgrpid);
1705CREATE TABLE widget (
1706	widgetid                 number(20)                                NOT NULL,
1707	dashboardid              number(20)                                NOT NULL,
1708	type                     nvarchar2(255)  DEFAULT ''                ,
1709	name                     nvarchar2(255)  DEFAULT ''                ,
1710	x                        number(10)      DEFAULT '0'               NOT NULL,
1711	y                        number(10)      DEFAULT '0'               NOT NULL,
1712	width                    number(10)      DEFAULT '1'               NOT NULL,
1713	height                   number(10)      DEFAULT '1'               NOT NULL,
1714	PRIMARY KEY (widgetid)
1715);
1716CREATE INDEX widget_1 ON widget (dashboardid);
1717CREATE TABLE widget_field (
1718	widget_fieldid           number(20)                                NOT NULL,
1719	widgetid                 number(20)                                NOT NULL,
1720	type                     number(10)      DEFAULT '0'               NOT NULL,
1721	name                     nvarchar2(255)  DEFAULT ''                ,
1722	value_int                number(10)      DEFAULT '0'               NOT NULL,
1723	value_str                nvarchar2(255)  DEFAULT ''                ,
1724	value_groupid            number(20)                                NULL,
1725	value_hostid             number(20)                                NULL,
1726	value_itemid             number(20)                                NULL,
1727	value_graphid            number(20)                                NULL,
1728	value_sysmapid           number(20)                                NULL,
1729	PRIMARY KEY (widget_fieldid)
1730);
1731CREATE INDEX widget_field_1 ON widget_field (widgetid);
1732CREATE INDEX widget_field_2 ON widget_field (value_groupid);
1733CREATE INDEX widget_field_3 ON widget_field (value_hostid);
1734CREATE INDEX widget_field_4 ON widget_field (value_itemid);
1735CREATE INDEX widget_field_5 ON widget_field (value_graphid);
1736CREATE INDEX widget_field_6 ON widget_field (value_sysmapid);
1737CREATE TABLE task_check_now (
1738	taskid                   number(20)                                NOT NULL,
1739	itemid                   number(20)                                NOT NULL,
1740	PRIMARY KEY (taskid)
1741);
1742CREATE TABLE event_suppress (
1743	event_suppressid         number(20)                                NOT NULL,
1744	eventid                  number(20)                                NOT NULL,
1745	maintenanceid            number(20)                                NULL,
1746	suppress_until           number(10)      DEFAULT '0'               NOT NULL,
1747	PRIMARY KEY (event_suppressid)
1748);
1749CREATE UNIQUE INDEX event_suppress_1 ON event_suppress (eventid,maintenanceid);
1750CREATE INDEX event_suppress_2 ON event_suppress (suppress_until);
1751CREATE INDEX event_suppress_3 ON event_suppress (maintenanceid);
1752CREATE TABLE maintenance_tag (
1753	maintenancetagid         number(20)                                NOT NULL,
1754	maintenanceid            number(20)                                NOT NULL,
1755	tag                      nvarchar2(255)  DEFAULT ''                ,
1756	operator                 number(10)      DEFAULT '2'               NOT NULL,
1757	value                    nvarchar2(255)  DEFAULT ''                ,
1758	PRIMARY KEY (maintenancetagid)
1759);
1760CREATE INDEX maintenance_tag_1 ON maintenance_tag (maintenanceid);
1761CREATE TABLE dbversion (
1762	mandatory                number(10)      DEFAULT '0'               NOT NULL,
1763	optional                 number(10)      DEFAULT '0'               NOT NULL
1764);
1765INSERT INTO dbversion VALUES ('4000000','4000006');
1766CREATE SEQUENCE proxy_history_seq
1767START WITH 1
1768INCREMENT BY 1
1769NOMAXVALUE
1770/
1771CREATE TRIGGER proxy_history_tr
1772BEFORE INSERT ON proxy_history
1773FOR EACH ROW
1774BEGIN
1775SELECT proxy_history_seq.nextval INTO :new.id FROM dual;
1776END;
1777/
1778CREATE SEQUENCE proxy_dhistory_seq
1779START WITH 1
1780INCREMENT BY 1
1781NOMAXVALUE
1782/
1783CREATE TRIGGER proxy_dhistory_tr
1784BEFORE INSERT ON proxy_dhistory
1785FOR EACH ROW
1786BEGIN
1787SELECT proxy_dhistory_seq.nextval INTO :new.id FROM dual;
1788END;
1789/
1790CREATE SEQUENCE proxy_autoreg_host_seq
1791START WITH 1
1792INCREMENT BY 1
1793NOMAXVALUE
1794/
1795CREATE TRIGGER proxy_autoreg_host_tr
1796BEFORE INSERT ON proxy_autoreg_host
1797FOR EACH ROW
1798BEGIN
1799SELECT proxy_autoreg_host_seq.nextval INTO :new.id FROM dual;
1800END;
1801/
1802ALTER TABLE hosts ADD CONSTRAINT c_hosts_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid);
1803ALTER TABLE hosts ADD CONSTRAINT c_hosts_2 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid);
1804ALTER TABLE hosts ADD CONSTRAINT c_hosts_3 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1805ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1806ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid);
1807ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_3 FOREIGN KEY (templateid) REFERENCES group_prototype (group_prototypeid) ON DELETE CASCADE;
1808ALTER TABLE group_discovery ADD CONSTRAINT c_group_discovery_1 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1809ALTER TABLE group_discovery ADD CONSTRAINT c_group_discovery_2 FOREIGN KEY (parent_group_prototypeid) REFERENCES group_prototype (group_prototypeid);
1810ALTER TABLE screens ADD CONSTRAINT c_screens_1 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1811ALTER TABLE screens ADD CONSTRAINT c_screens_3 FOREIGN KEY (userid) REFERENCES users (userid);
1812ALTER TABLE screens_items ADD CONSTRAINT c_screens_items_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1813ALTER TABLE screen_user ADD CONSTRAINT c_screen_user_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1814ALTER TABLE screen_user ADD CONSTRAINT c_screen_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1815ALTER TABLE screen_usrgrp ADD CONSTRAINT c_screen_usrgrp_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1816ALTER TABLE screen_usrgrp ADD CONSTRAINT c_screen_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1817ALTER TABLE slideshows ADD CONSTRAINT c_slideshows_3 FOREIGN KEY (userid) REFERENCES users (userid);
1818ALTER TABLE slideshow_user ADD CONSTRAINT c_slideshow_user_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1819ALTER TABLE slideshow_user ADD CONSTRAINT c_slideshow_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1820ALTER TABLE slideshow_usrgrp ADD CONSTRAINT c_slideshow_usrgrp_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1821ALTER TABLE slideshow_usrgrp ADD CONSTRAINT c_slideshow_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1822ALTER TABLE slides ADD CONSTRAINT c_slides_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1823ALTER TABLE slides ADD CONSTRAINT c_slides_2 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1824ALTER TABLE drules ADD CONSTRAINT c_drules_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid);
1825ALTER TABLE dchecks ADD CONSTRAINT c_dchecks_1 FOREIGN KEY (druleid) REFERENCES drules (druleid) ON DELETE CASCADE;
1826ALTER TABLE applications ADD CONSTRAINT c_applications_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1827ALTER TABLE httptest ADD CONSTRAINT c_httptest_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid);
1828ALTER TABLE httptest ADD CONSTRAINT c_httptest_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1829ALTER TABLE httptest ADD CONSTRAINT c_httptest_3 FOREIGN KEY (templateid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1830ALTER TABLE httpstep ADD CONSTRAINT c_httpstep_1 FOREIGN KEY (httptestid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1831ALTER TABLE interface ADD CONSTRAINT c_interface_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1832ALTER TABLE items ADD CONSTRAINT c_items_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1833ALTER TABLE items ADD CONSTRAINT c_items_2 FOREIGN KEY (templateid) REFERENCES items (itemid) ON DELETE CASCADE;
1834ALTER TABLE items ADD CONSTRAINT c_items_3 FOREIGN KEY (valuemapid) REFERENCES valuemaps (valuemapid);
1835ALTER TABLE items ADD CONSTRAINT c_items_4 FOREIGN KEY (interfaceid) REFERENCES interface (interfaceid);
1836ALTER TABLE items ADD CONSTRAINT c_items_5 FOREIGN KEY (master_itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1837ALTER TABLE httpstepitem ADD CONSTRAINT c_httpstepitem_1 FOREIGN KEY (httpstepid) REFERENCES httpstep (httpstepid) ON DELETE CASCADE;
1838ALTER TABLE httpstepitem ADD CONSTRAINT c_httpstepitem_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1839ALTER TABLE httptestitem ADD CONSTRAINT c_httptestitem_1 FOREIGN KEY (httptestid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1840ALTER TABLE httptestitem ADD CONSTRAINT c_httptestitem_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1841ALTER TABLE users_groups ADD CONSTRAINT c_users_groups_1 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1842ALTER TABLE users_groups ADD CONSTRAINT c_users_groups_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1843ALTER TABLE scripts ADD CONSTRAINT c_scripts_1 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid);
1844ALTER TABLE scripts ADD CONSTRAINT c_scripts_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid);
1845ALTER TABLE operations ADD CONSTRAINT c_operations_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1846ALTER TABLE opmessage ADD CONSTRAINT c_opmessage_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1847ALTER TABLE opmessage ADD CONSTRAINT c_opmessage_2 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid);
1848ALTER TABLE opmessage_grp ADD CONSTRAINT c_opmessage_grp_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1849ALTER TABLE opmessage_grp ADD CONSTRAINT c_opmessage_grp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid);
1850ALTER TABLE opmessage_usr ADD CONSTRAINT c_opmessage_usr_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1851ALTER TABLE opmessage_usr ADD CONSTRAINT c_opmessage_usr_2 FOREIGN KEY (userid) REFERENCES users (userid);
1852ALTER TABLE opcommand ADD CONSTRAINT c_opcommand_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1853ALTER TABLE opcommand ADD CONSTRAINT c_opcommand_2 FOREIGN KEY (scriptid) REFERENCES scripts (scriptid);
1854ALTER TABLE opcommand_hst ADD CONSTRAINT c_opcommand_hst_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1855ALTER TABLE opcommand_hst ADD CONSTRAINT c_opcommand_hst_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid);
1856ALTER TABLE opcommand_grp ADD CONSTRAINT c_opcommand_grp_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1857ALTER TABLE opcommand_grp ADD CONSTRAINT c_opcommand_grp_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid);
1858ALTER TABLE opgroup ADD CONSTRAINT c_opgroup_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1859ALTER TABLE opgroup ADD CONSTRAINT c_opgroup_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid);
1860ALTER TABLE optemplate ADD CONSTRAINT c_optemplate_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1861ALTER TABLE optemplate ADD CONSTRAINT c_optemplate_2 FOREIGN KEY (templateid) REFERENCES hosts (hostid);
1862ALTER TABLE opconditions ADD CONSTRAINT c_opconditions_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1863ALTER TABLE conditions ADD CONSTRAINT c_conditions_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1864ALTER TABLE config ADD CONSTRAINT c_config_1 FOREIGN KEY (alert_usrgrpid) REFERENCES usrgrp (usrgrpid);
1865ALTER TABLE config ADD CONSTRAINT c_config_2 FOREIGN KEY (discovery_groupid) REFERENCES hstgrp (groupid);
1866ALTER TABLE triggers ADD CONSTRAINT c_triggers_1 FOREIGN KEY (templateid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1867ALTER TABLE trigger_depends ADD CONSTRAINT c_trigger_depends_1 FOREIGN KEY (triggerid_down) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1868ALTER TABLE trigger_depends ADD CONSTRAINT c_trigger_depends_2 FOREIGN KEY (triggerid_up) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1869ALTER TABLE functions ADD CONSTRAINT c_functions_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1870ALTER TABLE functions ADD CONSTRAINT c_functions_2 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1871ALTER TABLE graphs ADD CONSTRAINT c_graphs_1 FOREIGN KEY (templateid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1872ALTER TABLE graphs ADD CONSTRAINT c_graphs_2 FOREIGN KEY (ymin_itemid) REFERENCES items (itemid);
1873ALTER TABLE graphs ADD CONSTRAINT c_graphs_3 FOREIGN KEY (ymax_itemid) REFERENCES items (itemid);
1874ALTER TABLE graphs_items ADD CONSTRAINT c_graphs_items_1 FOREIGN KEY (graphid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1875ALTER TABLE graphs_items ADD CONSTRAINT c_graphs_items_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1876ALTER TABLE hostmacro ADD CONSTRAINT c_hostmacro_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1877ALTER TABLE hosts_groups ADD CONSTRAINT c_hosts_groups_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1878ALTER TABLE hosts_groups ADD CONSTRAINT c_hosts_groups_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1879ALTER TABLE hosts_templates ADD CONSTRAINT c_hosts_templates_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1880ALTER TABLE hosts_templates ADD CONSTRAINT c_hosts_templates_2 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1881ALTER TABLE items_applications ADD CONSTRAINT c_items_applications_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1882ALTER TABLE items_applications ADD CONSTRAINT c_items_applications_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1883ALTER TABLE mappings ADD CONSTRAINT c_mappings_1 FOREIGN KEY (valuemapid) REFERENCES valuemaps (valuemapid) ON DELETE CASCADE;
1884ALTER TABLE media ADD CONSTRAINT c_media_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1885ALTER TABLE media ADD CONSTRAINT c_media_2 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid) ON DELETE CASCADE;
1886ALTER TABLE rights ADD CONSTRAINT c_rights_1 FOREIGN KEY (groupid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1887ALTER TABLE rights ADD CONSTRAINT c_rights_2 FOREIGN KEY (id) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1888ALTER TABLE services ADD CONSTRAINT c_services_1 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1889ALTER TABLE services_links ADD CONSTRAINT c_services_links_1 FOREIGN KEY (serviceupid) REFERENCES services (serviceid) ON DELETE CASCADE;
1890ALTER TABLE services_links ADD CONSTRAINT c_services_links_2 FOREIGN KEY (servicedownid) REFERENCES services (serviceid) ON DELETE CASCADE;
1891ALTER TABLE services_times ADD CONSTRAINT c_services_times_1 FOREIGN KEY (serviceid) REFERENCES services (serviceid) ON DELETE CASCADE;
1892ALTER TABLE icon_map ADD CONSTRAINT c_icon_map_1 FOREIGN KEY (default_iconid) REFERENCES images (imageid);
1893ALTER TABLE icon_mapping ADD CONSTRAINT c_icon_mapping_1 FOREIGN KEY (iconmapid) REFERENCES icon_map (iconmapid) ON DELETE CASCADE;
1894ALTER TABLE icon_mapping ADD CONSTRAINT c_icon_mapping_2 FOREIGN KEY (iconid) REFERENCES images (imageid);
1895ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_1 FOREIGN KEY (backgroundid) REFERENCES images (imageid);
1896ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_2 FOREIGN KEY (iconmapid) REFERENCES icon_map (iconmapid);
1897ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_3 FOREIGN KEY (userid) REFERENCES users (userid);
1898ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1899ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_2 FOREIGN KEY (iconid_off) REFERENCES images (imageid);
1900ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_3 FOREIGN KEY (iconid_on) REFERENCES images (imageid);
1901ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_4 FOREIGN KEY (iconid_disabled) REFERENCES images (imageid);
1902ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_5 FOREIGN KEY (iconid_maintenance) REFERENCES images (imageid);
1903ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1904ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_2 FOREIGN KEY (selementid1) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1905ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_3 FOREIGN KEY (selementid2) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1906ALTER TABLE sysmaps_link_triggers ADD CONSTRAINT c_sysmaps_link_triggers_1 FOREIGN KEY (linkid) REFERENCES sysmaps_links (linkid) ON DELETE CASCADE;
1907ALTER TABLE sysmaps_link_triggers ADD CONSTRAINT c_sysmaps_link_triggers_2 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1908ALTER TABLE sysmap_element_url ADD CONSTRAINT c_sysmap_element_url_1 FOREIGN KEY (selementid) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1909ALTER TABLE sysmap_url ADD CONSTRAINT c_sysmap_url_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1910ALTER TABLE sysmap_user ADD CONSTRAINT c_sysmap_user_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1911ALTER TABLE sysmap_user ADD CONSTRAINT c_sysmap_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1912ALTER TABLE sysmap_usrgrp ADD CONSTRAINT c_sysmap_usrgrp_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1913ALTER TABLE sysmap_usrgrp ADD CONSTRAINT c_sysmap_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1914ALTER TABLE maintenances_hosts ADD CONSTRAINT c_maintenances_hosts_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1915ALTER TABLE maintenances_hosts ADD CONSTRAINT c_maintenances_hosts_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1916ALTER TABLE maintenances_groups ADD CONSTRAINT c_maintenances_groups_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1917ALTER TABLE maintenances_groups ADD CONSTRAINT c_maintenances_groups_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1918ALTER TABLE maintenances_windows ADD CONSTRAINT c_maintenances_windows_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1919ALTER TABLE maintenances_windows ADD CONSTRAINT c_maintenances_windows_2 FOREIGN KEY (timeperiodid) REFERENCES timeperiods (timeperiodid) ON DELETE CASCADE;
1920ALTER TABLE expressions ADD CONSTRAINT c_expressions_1 FOREIGN KEY (regexpid) REFERENCES regexps (regexpid) ON DELETE CASCADE;
1921ALTER TABLE alerts ADD CONSTRAINT c_alerts_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1922ALTER TABLE alerts ADD CONSTRAINT c_alerts_2 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1923ALTER TABLE alerts ADD CONSTRAINT c_alerts_3 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1924ALTER TABLE alerts ADD CONSTRAINT c_alerts_4 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid) ON DELETE CASCADE;
1925ALTER TABLE alerts ADD CONSTRAINT c_alerts_5 FOREIGN KEY (p_eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1926ALTER TABLE alerts ADD CONSTRAINT c_alerts_6 FOREIGN KEY (acknowledgeid) REFERENCES acknowledges (acknowledgeid) ON DELETE CASCADE;
1927ALTER TABLE acknowledges ADD CONSTRAINT c_acknowledges_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1928ALTER TABLE acknowledges ADD CONSTRAINT c_acknowledges_2 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1929ALTER TABLE auditlog ADD CONSTRAINT c_auditlog_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1930ALTER TABLE auditlog_details ADD CONSTRAINT c_auditlog_details_1 FOREIGN KEY (auditid) REFERENCES auditlog (auditid) ON DELETE CASCADE;
1931ALTER TABLE service_alarms ADD CONSTRAINT c_service_alarms_1 FOREIGN KEY (serviceid) REFERENCES services (serviceid) ON DELETE CASCADE;
1932ALTER TABLE autoreg_host ADD CONSTRAINT c_autoreg_host_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1933ALTER TABLE dhosts ADD CONSTRAINT c_dhosts_1 FOREIGN KEY (druleid) REFERENCES drules (druleid) ON DELETE CASCADE;
1934ALTER TABLE dservices ADD CONSTRAINT c_dservices_1 FOREIGN KEY (dhostid) REFERENCES dhosts (dhostid) ON DELETE CASCADE;
1935ALTER TABLE dservices ADD CONSTRAINT c_dservices_2 FOREIGN KEY (dcheckid) REFERENCES dchecks (dcheckid) ON DELETE CASCADE;
1936ALTER TABLE graph_discovery ADD CONSTRAINT c_graph_discovery_1 FOREIGN KEY (graphid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1937ALTER TABLE graph_discovery ADD CONSTRAINT c_graph_discovery_2 FOREIGN KEY (parent_graphid) REFERENCES graphs (graphid);
1938ALTER TABLE host_inventory ADD CONSTRAINT c_host_inventory_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1939ALTER TABLE item_discovery ADD CONSTRAINT c_item_discovery_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1940ALTER TABLE item_discovery ADD CONSTRAINT c_item_discovery_2 FOREIGN KEY (parent_itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1941ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1942ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_2 FOREIGN KEY (parent_hostid) REFERENCES hosts (hostid);
1943ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_3 FOREIGN KEY (parent_itemid) REFERENCES items (itemid);
1944ALTER TABLE interface_discovery ADD CONSTRAINT c_interface_discovery_1 FOREIGN KEY (interfaceid) REFERENCES interface (interfaceid) ON DELETE CASCADE;
1945ALTER TABLE interface_discovery ADD CONSTRAINT c_interface_discovery_2 FOREIGN KEY (parent_interfaceid) REFERENCES interface (interfaceid) ON DELETE CASCADE;
1946ALTER TABLE profiles ADD CONSTRAINT c_profiles_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1947ALTER TABLE sessions ADD CONSTRAINT c_sessions_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1948ALTER TABLE trigger_discovery ADD CONSTRAINT c_trigger_discovery_1 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1949ALTER TABLE trigger_discovery ADD CONSTRAINT c_trigger_discovery_2 FOREIGN KEY (parent_triggerid) REFERENCES triggers (triggerid);
1950ALTER TABLE application_template ADD CONSTRAINT c_application_template_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1951ALTER TABLE application_template ADD CONSTRAINT c_application_template_2 FOREIGN KEY (templateid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1952ALTER TABLE item_condition ADD CONSTRAINT c_item_condition_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1953ALTER TABLE application_prototype ADD CONSTRAINT c_application_prototype_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1954ALTER TABLE application_prototype ADD CONSTRAINT c_application_prototype_2 FOREIGN KEY (templateid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1955ALTER TABLE item_application_prototype ADD CONSTRAINT c_item_application_prototype_1 FOREIGN KEY (application_prototypeid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1956ALTER TABLE item_application_prototype ADD CONSTRAINT c_item_application_prototype_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1957ALTER TABLE application_discovery ADD CONSTRAINT c_application_discovery_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1958ALTER TABLE application_discovery ADD CONSTRAINT c_application_discovery_2 FOREIGN KEY (application_prototypeid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1959ALTER TABLE opinventory ADD CONSTRAINT c_opinventory_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1960ALTER TABLE trigger_tag ADD CONSTRAINT c_trigger_tag_1 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1961ALTER TABLE event_tag ADD CONSTRAINT c_event_tag_1 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1962ALTER TABLE problem ADD CONSTRAINT c_problem_1 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1963ALTER TABLE problem ADD CONSTRAINT c_problem_2 FOREIGN KEY (r_eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1964ALTER TABLE problem_tag ADD CONSTRAINT c_problem_tag_1 FOREIGN KEY (eventid) REFERENCES problem (eventid) ON DELETE CASCADE;
1965ALTER TABLE tag_filter ADD CONSTRAINT c_tag_filter_1 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1966ALTER TABLE tag_filter ADD CONSTRAINT c_tag_filter_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1967ALTER TABLE event_recovery ADD CONSTRAINT c_event_recovery_1 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1968ALTER TABLE event_recovery ADD CONSTRAINT c_event_recovery_2 FOREIGN KEY (r_eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1969ALTER TABLE event_recovery ADD CONSTRAINT c_event_recovery_3 FOREIGN KEY (c_eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1970ALTER TABLE corr_condition ADD CONSTRAINT c_corr_condition_1 FOREIGN KEY (correlationid) REFERENCES correlation (correlationid) ON DELETE CASCADE;
1971ALTER TABLE corr_condition_tag ADD CONSTRAINT c_corr_condition_tag_1 FOREIGN KEY (corr_conditionid) REFERENCES corr_condition (corr_conditionid) ON DELETE CASCADE;
1972ALTER TABLE corr_condition_group ADD CONSTRAINT c_corr_condition_group_1 FOREIGN KEY (corr_conditionid) REFERENCES corr_condition (corr_conditionid) ON DELETE CASCADE;
1973ALTER TABLE corr_condition_group ADD CONSTRAINT c_corr_condition_group_2 FOREIGN KEY (groupid) REFERENCES hstgrp (groupid);
1974ALTER TABLE corr_condition_tagpair ADD CONSTRAINT c_corr_condition_tagpair_1 FOREIGN KEY (corr_conditionid) REFERENCES corr_condition (corr_conditionid) ON DELETE CASCADE;
1975ALTER TABLE corr_condition_tagvalue ADD CONSTRAINT c_corr_condition_tagvalue_1 FOREIGN KEY (corr_conditionid) REFERENCES corr_condition (corr_conditionid) ON DELETE CASCADE;
1976ALTER TABLE corr_operation ADD CONSTRAINT c_corr_operation_1 FOREIGN KEY (correlationid) REFERENCES correlation (correlationid) ON DELETE CASCADE;
1977ALTER TABLE task ADD CONSTRAINT c_task_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1978ALTER TABLE task_close_problem ADD CONSTRAINT c_task_close_problem_1 FOREIGN KEY (taskid) REFERENCES task (taskid) ON DELETE CASCADE;
1979ALTER TABLE item_preproc ADD CONSTRAINT c_item_preproc_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1980ALTER TABLE task_remote_command ADD CONSTRAINT c_task_remote_command_1 FOREIGN KEY (taskid) REFERENCES task (taskid) ON DELETE CASCADE;
1981ALTER TABLE task_remote_command_result ADD CONSTRAINT c_task_remote_command_result_1 FOREIGN KEY (taskid) REFERENCES task (taskid) ON DELETE CASCADE;
1982ALTER TABLE task_acknowledge ADD CONSTRAINT c_task_acknowledge_1 FOREIGN KEY (taskid) REFERENCES task (taskid) ON DELETE CASCADE;
1983ALTER TABLE sysmap_shape ADD CONSTRAINT c_sysmap_shape_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1984ALTER TABLE sysmap_element_trigger ADD CONSTRAINT c_sysmap_element_trigger_1 FOREIGN KEY (selementid) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1985ALTER TABLE sysmap_element_trigger ADD CONSTRAINT c_sysmap_element_trigger_2 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1986ALTER TABLE httptest_field ADD CONSTRAINT c_httptest_field_1 FOREIGN KEY (httptestid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1987ALTER TABLE httpstep_field ADD CONSTRAINT c_httpstep_field_1 FOREIGN KEY (httpstepid) REFERENCES httpstep (httpstepid) ON DELETE CASCADE;
1988ALTER TABLE dashboard ADD CONSTRAINT c_dashboard_1 FOREIGN KEY (userid) REFERENCES users (userid);
1989ALTER TABLE dashboard_user ADD CONSTRAINT c_dashboard_user_1 FOREIGN KEY (dashboardid) REFERENCES dashboard (dashboardid) ON DELETE CASCADE;
1990ALTER TABLE dashboard_user ADD CONSTRAINT c_dashboard_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1991ALTER TABLE dashboard_usrgrp ADD CONSTRAINT c_dashboard_usrgrp_1 FOREIGN KEY (dashboardid) REFERENCES dashboard (dashboardid) ON DELETE CASCADE;
1992ALTER TABLE dashboard_usrgrp ADD CONSTRAINT c_dashboard_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1993ALTER TABLE widget ADD CONSTRAINT c_widget_1 FOREIGN KEY (dashboardid) REFERENCES dashboard (dashboardid) ON DELETE CASCADE;
1994ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_1 FOREIGN KEY (widgetid) REFERENCES widget (widgetid) ON DELETE CASCADE;
1995ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_2 FOREIGN KEY (value_groupid) REFERENCES hstgrp (groupid) ON DELETE CASCADE;
1996ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_3 FOREIGN KEY (value_hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1997ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_4 FOREIGN KEY (value_itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1998ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_5 FOREIGN KEY (value_graphid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1999ALTER TABLE widget_field ADD CONSTRAINT c_widget_field_6 FOREIGN KEY (value_sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
2000ALTER TABLE task_check_now ADD CONSTRAINT c_task_check_now_1 FOREIGN KEY (taskid) REFERENCES task (taskid) ON DELETE CASCADE;
2001ALTER TABLE event_suppress ADD CONSTRAINT c_event_suppress_1 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
2002ALTER TABLE event_suppress ADD CONSTRAINT c_event_suppress_2 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
2003ALTER TABLE maintenance_tag ADD CONSTRAINT c_maintenance_tag_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
2004