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               number(10)      DEFAULT '900'             NOT NULL,
10	lang                     nvarchar2(5)    DEFAULT 'en_GB'           ,
11	refresh                  number(10)      DEFAULT '30'              NOT NULL,
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	PRIMARY KEY (maintenanceid)
29);
30CREATE INDEX maintenances_1 ON maintenances (active_since,active_till);
31CREATE UNIQUE INDEX maintenances_2 ON maintenances (name);
32CREATE TABLE hosts (
33	hostid                   number(20)                                NOT NULL,
34	proxy_hostid             number(20)                                NULL,
35	host                     nvarchar2(128)  DEFAULT ''                ,
36	status                   number(10)      DEFAULT '0'               NOT NULL,
37	disable_until            number(10)      DEFAULT '0'               NOT NULL,
38	error                    nvarchar2(2048) DEFAULT ''                ,
39	available                number(10)      DEFAULT '0'               NOT NULL,
40	errors_from              number(10)      DEFAULT '0'               NOT NULL,
41	lastaccess               number(10)      DEFAULT '0'               NOT NULL,
42	ipmi_authtype            number(10)      DEFAULT '0'               NOT NULL,
43	ipmi_privilege           number(10)      DEFAULT '2'               NOT NULL,
44	ipmi_username            nvarchar2(16)   DEFAULT ''                ,
45	ipmi_password            nvarchar2(20)   DEFAULT ''                ,
46	ipmi_disable_until       number(10)      DEFAULT '0'               NOT NULL,
47	ipmi_available           number(10)      DEFAULT '0'               NOT NULL,
48	snmp_disable_until       number(10)      DEFAULT '0'               NOT NULL,
49	snmp_available           number(10)      DEFAULT '0'               NOT NULL,
50	maintenanceid            number(20)                                NULL,
51	maintenance_status       number(10)      DEFAULT '0'               NOT NULL,
52	maintenance_type         number(10)      DEFAULT '0'               NOT NULL,
53	maintenance_from         number(10)      DEFAULT '0'               NOT NULL,
54	ipmi_errors_from         number(10)      DEFAULT '0'               NOT NULL,
55	snmp_errors_from         number(10)      DEFAULT '0'               NOT NULL,
56	ipmi_error               nvarchar2(2048) DEFAULT ''                ,
57	snmp_error               nvarchar2(2048) DEFAULT ''                ,
58	jmx_disable_until        number(10)      DEFAULT '0'               NOT NULL,
59	jmx_available            number(10)      DEFAULT '0'               NOT NULL,
60	jmx_errors_from          number(10)      DEFAULT '0'               NOT NULL,
61	jmx_error                nvarchar2(2048) DEFAULT ''                ,
62	name                     nvarchar2(128)  DEFAULT ''                ,
63	flags                    number(10)      DEFAULT '0'               NOT NULL,
64	templateid               number(20)                                NULL,
65	description              nvarchar2(2048) DEFAULT ''                ,
66	tls_connect              number(10)      DEFAULT '1'               NOT NULL,
67	tls_accept               number(10)      DEFAULT '1'               NOT NULL,
68	tls_issuer               nvarchar2(1024) DEFAULT ''                ,
69	tls_subject              nvarchar2(1024) DEFAULT ''                ,
70	tls_psk_identity         nvarchar2(128)  DEFAULT ''                ,
71	tls_psk                  nvarchar2(512)  DEFAULT ''                ,
72	PRIMARY KEY (hostid)
73);
74CREATE INDEX hosts_1 ON hosts (host);
75CREATE INDEX hosts_2 ON hosts (status);
76CREATE INDEX hosts_3 ON hosts (proxy_hostid);
77CREATE INDEX hosts_4 ON hosts (name);
78CREATE INDEX hosts_5 ON hosts (maintenanceid);
79CREATE TABLE groups (
80	groupid                  number(20)                                NOT NULL,
81	name                     nvarchar2(64)   DEFAULT ''                ,
82	internal                 number(10)      DEFAULT '0'               NOT NULL,
83	flags                    number(10)      DEFAULT '0'               NOT NULL,
84	PRIMARY KEY (groupid)
85);
86CREATE INDEX groups_1 ON groups (name);
87CREATE TABLE group_prototype (
88	group_prototypeid        number(20)                                NOT NULL,
89	hostid                   number(20)                                NOT NULL,
90	name                     nvarchar2(64)   DEFAULT ''                ,
91	groupid                  number(20)                                NULL,
92	templateid               number(20)                                NULL,
93	PRIMARY KEY (group_prototypeid)
94);
95CREATE INDEX group_prototype_1 ON group_prototype (hostid);
96CREATE TABLE group_discovery (
97	groupid                  number(20)                                NOT NULL,
98	parent_group_prototypeid number(20)                                NOT NULL,
99	name                     nvarchar2(64)   DEFAULT ''                ,
100	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
101	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
102	PRIMARY KEY (groupid)
103);
104CREATE TABLE screens (
105	screenid                 number(20)                                NOT NULL,
106	name                     nvarchar2(255)                            ,
107	hsize                    number(10)      DEFAULT '1'               NOT NULL,
108	vsize                    number(10)      DEFAULT '1'               NOT NULL,
109	templateid               number(20)                                NULL,
110	userid                   number(20)                                NULL,
111	private                  number(10)      DEFAULT '1'               NOT NULL,
112	PRIMARY KEY (screenid)
113);
114CREATE INDEX screens_1 ON screens (templateid);
115CREATE TABLE screens_items (
116	screenitemid             number(20)                                NOT NULL,
117	screenid                 number(20)                                NOT NULL,
118	resourcetype             number(10)      DEFAULT '0'               NOT NULL,
119	resourceid               number(20)      DEFAULT '0'               NOT NULL,
120	width                    number(10)      DEFAULT '320'             NOT NULL,
121	height                   number(10)      DEFAULT '200'             NOT NULL,
122	x                        number(10)      DEFAULT '0'               NOT NULL,
123	y                        number(10)      DEFAULT '0'               NOT NULL,
124	colspan                  number(10)      DEFAULT '1'               NOT NULL,
125	rowspan                  number(10)      DEFAULT '1'               NOT NULL,
126	elements                 number(10)      DEFAULT '25'              NOT NULL,
127	valign                   number(10)      DEFAULT '0'               NOT NULL,
128	halign                   number(10)      DEFAULT '0'               NOT NULL,
129	style                    number(10)      DEFAULT '0'               NOT NULL,
130	url                      nvarchar2(255)  DEFAULT ''                ,
131	dynamic                  number(10)      DEFAULT '0'               NOT NULL,
132	sort_triggers            number(10)      DEFAULT '0'               NOT NULL,
133	application              nvarchar2(255)  DEFAULT ''                ,
134	max_columns              number(10)      DEFAULT '3'               NOT NULL,
135	PRIMARY KEY (screenitemid)
136);
137CREATE INDEX screens_items_1 ON screens_items (screenid);
138CREATE TABLE screen_user (
139	screenuserid             number(20)                                NOT NULL,
140	screenid                 number(20)                                NOT NULL,
141	userid                   number(20)                                NOT NULL,
142	permission               number(10)      DEFAULT '2'               NOT NULL,
143	PRIMARY KEY (screenuserid)
144);
145CREATE UNIQUE INDEX screen_user_1 ON screen_user (screenid,userid);
146CREATE TABLE screen_usrgrp (
147	screenusrgrpid           number(20)                                NOT NULL,
148	screenid                 number(20)                                NOT NULL,
149	usrgrpid                 number(20)                                NOT NULL,
150	permission               number(10)      DEFAULT '2'               NOT NULL,
151	PRIMARY KEY (screenusrgrpid)
152);
153CREATE UNIQUE INDEX screen_usrgrp_1 ON screen_usrgrp (screenid,usrgrpid);
154CREATE TABLE slideshows (
155	slideshowid              number(20)                                NOT NULL,
156	name                     nvarchar2(255)  DEFAULT ''                ,
157	delay                    number(10)      DEFAULT '0'               NOT NULL,
158	userid                   number(20)                                NOT NULL,
159	private                  number(10)      DEFAULT '1'               NOT NULL,
160	PRIMARY KEY (slideshowid)
161);
162CREATE UNIQUE INDEX slideshows_1 ON slideshows (name);
163CREATE TABLE slideshow_user (
164	slideshowuserid          number(20)                                NOT NULL,
165	slideshowid              number(20)                                NOT NULL,
166	userid                   number(20)                                NOT NULL,
167	permission               number(10)      DEFAULT '2'               NOT NULL,
168	PRIMARY KEY (slideshowuserid)
169);
170CREATE UNIQUE INDEX slideshow_user_1 ON slideshow_user (slideshowid,userid);
171CREATE TABLE slideshow_usrgrp (
172	slideshowusrgrpid        number(20)                                NOT NULL,
173	slideshowid              number(20)                                NOT NULL,
174	usrgrpid                 number(20)                                NOT NULL,
175	permission               number(10)      DEFAULT '2'               NOT NULL,
176	PRIMARY KEY (slideshowusrgrpid)
177);
178CREATE UNIQUE INDEX slideshow_usrgrp_1 ON slideshow_usrgrp (slideshowid,usrgrpid);
179CREATE TABLE slides (
180	slideid                  number(20)                                NOT NULL,
181	slideshowid              number(20)                                NOT NULL,
182	screenid                 number(20)                                NOT NULL,
183	step                     number(10)      DEFAULT '0'               NOT NULL,
184	delay                    number(10)      DEFAULT '0'               NOT NULL,
185	PRIMARY KEY (slideid)
186);
187CREATE INDEX slides_1 ON slides (slideshowid);
188CREATE INDEX slides_2 ON slides (screenid);
189CREATE TABLE drules (
190	druleid                  number(20)                                NOT NULL,
191	proxy_hostid             number(20)                                NULL,
192	name                     nvarchar2(255)  DEFAULT ''                ,
193	iprange                  nvarchar2(2048) DEFAULT ''                ,
194	delay                    number(10)      DEFAULT '3600'            NOT NULL,
195	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
196	status                   number(10)      DEFAULT '0'               NOT NULL,
197	PRIMARY KEY (druleid)
198);
199CREATE INDEX drules_1 ON drules (proxy_hostid);
200CREATE UNIQUE INDEX drules_2 ON drules (name);
201CREATE TABLE dchecks (
202	dcheckid                 number(20)                                NOT NULL,
203	druleid                  number(20)                                NOT NULL,
204	type                     number(10)      DEFAULT '0'               NOT NULL,
205	key_                     nvarchar2(255)  DEFAULT ''                ,
206	snmp_community           nvarchar2(255)  DEFAULT ''                ,
207	ports                    nvarchar2(255)  DEFAULT '0'               ,
208	snmpv3_securityname      nvarchar2(64)   DEFAULT ''                ,
209	snmpv3_securitylevel     number(10)      DEFAULT '0'               NOT NULL,
210	snmpv3_authpassphrase    nvarchar2(64)   DEFAULT ''                ,
211	snmpv3_privpassphrase    nvarchar2(64)   DEFAULT ''                ,
212	uniq                     number(10)      DEFAULT '0'               NOT NULL,
213	snmpv3_authprotocol      number(10)      DEFAULT '0'               NOT NULL,
214	snmpv3_privprotocol      number(10)      DEFAULT '0'               NOT NULL,
215	snmpv3_contextname       nvarchar2(255)  DEFAULT ''                ,
216	PRIMARY KEY (dcheckid)
217);
218CREATE INDEX dchecks_1 ON dchecks (druleid);
219CREATE TABLE applications (
220	applicationid            number(20)                                NOT NULL,
221	hostid                   number(20)                                NOT NULL,
222	name                     nvarchar2(255)  DEFAULT ''                ,
223	flags                    number(10)      DEFAULT '0'               NOT NULL,
224	PRIMARY KEY (applicationid)
225);
226CREATE UNIQUE INDEX applications_2 ON applications (hostid,name);
227CREATE TABLE httptest (
228	httptestid               number(20)                                NOT NULL,
229	name                     nvarchar2(64)   DEFAULT ''                ,
230	applicationid            number(20)                                NULL,
231	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
232	delay                    number(10)      DEFAULT '60'              NOT NULL,
233	status                   number(10)      DEFAULT '0'               NOT NULL,
234	variables                nvarchar2(2048) DEFAULT ''                ,
235	agent                    nvarchar2(255)  DEFAULT 'Zabbix'          ,
236	authentication           number(10)      DEFAULT '0'               NOT NULL,
237	http_user                nvarchar2(64)   DEFAULT ''                ,
238	http_password            nvarchar2(64)   DEFAULT ''                ,
239	hostid                   number(20)                                NOT NULL,
240	templateid               number(20)                                NULL,
241	http_proxy               nvarchar2(255)  DEFAULT ''                ,
242	retries                  number(10)      DEFAULT '1'               NOT NULL,
243	ssl_cert_file            nvarchar2(255)  DEFAULT ''                ,
244	ssl_key_file             nvarchar2(255)  DEFAULT ''                ,
245	ssl_key_password         nvarchar2(64)   DEFAULT ''                ,
246	verify_peer              number(10)      DEFAULT '0'               NOT NULL,
247	verify_host              number(10)      DEFAULT '0'               NOT NULL,
248	headers                  nvarchar2(2048) DEFAULT ''                ,
249	PRIMARY KEY (httptestid)
250);
251CREATE INDEX httptest_1 ON httptest (applicationid);
252CREATE UNIQUE INDEX httptest_2 ON httptest (hostid,name);
253CREATE INDEX httptest_3 ON httptest (status);
254CREATE INDEX httptest_4 ON httptest (templateid);
255CREATE TABLE httpstep (
256	httpstepid               number(20)                                NOT NULL,
257	httptestid               number(20)                                NOT NULL,
258	name                     nvarchar2(64)   DEFAULT ''                ,
259	no                       number(10)      DEFAULT '0'               NOT NULL,
260	url                      nvarchar2(2048) DEFAULT ''                ,
261	timeout                  number(10)      DEFAULT '15'              NOT NULL,
262	posts                    nvarchar2(2048) DEFAULT ''                ,
263	required                 nvarchar2(255)  DEFAULT ''                ,
264	status_codes             nvarchar2(255)  DEFAULT ''                ,
265	variables                nvarchar2(2048) DEFAULT ''                ,
266	follow_redirects         number(10)      DEFAULT '1'               NOT NULL,
267	retrieve_mode            number(10)      DEFAULT '0'               NOT NULL,
268	headers                  nvarchar2(2048) DEFAULT ''                ,
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(64)   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(255)  DEFAULT ''                ,
297	hostid                   number(20)                                NOT NULL,
298	name                     nvarchar2(255)  DEFAULT ''                ,
299	key_                     nvarchar2(255)  DEFAULT ''                ,
300	delay                    number(10)      DEFAULT '0'               NOT NULL,
301	history                  number(10)      DEFAULT '90'              NOT NULL,
302	trends                   number(10)      DEFAULT '365'             NOT NULL,
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	multiplier               number(10)      DEFAULT '0'               NOT NULL,
308	delta                    number(10)      DEFAULT '0'               NOT NULL,
309	snmpv3_securityname      nvarchar2(64)   DEFAULT ''                ,
310	snmpv3_securitylevel     number(10)      DEFAULT '0'               NOT NULL,
311	snmpv3_authpassphrase    nvarchar2(64)   DEFAULT ''                ,
312	snmpv3_privpassphrase    nvarchar2(64)   DEFAULT ''                ,
313	formula                  nvarchar2(255)  DEFAULT ''                ,
314	error                    nvarchar2(2048) DEFAULT ''                ,
315	lastlogsize              number(20)      DEFAULT '0'               NOT NULL,
316	logtimefmt               nvarchar2(64)   DEFAULT ''                ,
317	templateid               number(20)                                NULL,
318	valuemapid               number(20)                                NULL,
319	delay_flex               nvarchar2(255)  DEFAULT ''                ,
320	params                   nvarchar2(2048) DEFAULT ''                ,
321	ipmi_sensor              nvarchar2(128)  DEFAULT ''                ,
322	data_type                number(10)      DEFAULT '0'               NOT NULL,
323	authtype                 number(10)      DEFAULT '0'               NOT NULL,
324	username                 nvarchar2(64)   DEFAULT ''                ,
325	password                 nvarchar2(64)   DEFAULT ''                ,
326	publickey                nvarchar2(64)   DEFAULT ''                ,
327	privatekey               nvarchar2(64)   DEFAULT ''                ,
328	mtime                    number(10)      DEFAULT '0'               NOT NULL,
329	flags                    number(10)      DEFAULT '0'               NOT NULL,
330	interfaceid              number(20)                                NULL,
331	port                     nvarchar2(64)   DEFAULT ''                ,
332	description              nvarchar2(2048) DEFAULT ''                ,
333	inventory_link           number(10)      DEFAULT '0'               NOT NULL,
334	lifetime                 nvarchar2(64)   DEFAULT '30'              ,
335	snmpv3_authprotocol      number(10)      DEFAULT '0'               NOT NULL,
336	snmpv3_privprotocol      number(10)      DEFAULT '0'               NOT NULL,
337	state                    number(10)      DEFAULT '0'               NOT NULL,
338	snmpv3_contextname       nvarchar2(255)  DEFAULT ''                ,
339	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
340	PRIMARY KEY (itemid)
341);
342CREATE UNIQUE INDEX items_1 ON items (hostid,key_);
343CREATE INDEX items_3 ON items (status);
344CREATE INDEX items_4 ON items (templateid);
345CREATE INDEX items_5 ON items (valuemapid);
346CREATE INDEX items_6 ON items (interfaceid);
347CREATE TABLE httpstepitem (
348	httpstepitemid           number(20)                                NOT NULL,
349	httpstepid               number(20)                                NOT NULL,
350	itemid                   number(20)                                NOT NULL,
351	type                     number(10)      DEFAULT '0'               NOT NULL,
352	PRIMARY KEY (httpstepitemid)
353);
354CREATE UNIQUE INDEX httpstepitem_1 ON httpstepitem (httpstepid,itemid);
355CREATE INDEX httpstepitem_2 ON httpstepitem (itemid);
356CREATE TABLE httptestitem (
357	httptestitemid           number(20)                                NOT NULL,
358	httptestid               number(20)                                NOT NULL,
359	itemid                   number(20)                                NOT NULL,
360	type                     number(10)      DEFAULT '0'               NOT NULL,
361	PRIMARY KEY (httptestitemid)
362);
363CREATE UNIQUE INDEX httptestitem_1 ON httptestitem (httptestid,itemid);
364CREATE INDEX httptestitem_2 ON httptestitem (itemid);
365CREATE TABLE media_type (
366	mediatypeid              number(20)                                NOT NULL,
367	type                     number(10)      DEFAULT '0'               NOT NULL,
368	description              nvarchar2(100)  DEFAULT ''                ,
369	smtp_server              nvarchar2(255)  DEFAULT ''                ,
370	smtp_helo                nvarchar2(255)  DEFAULT ''                ,
371	smtp_email               nvarchar2(255)  DEFAULT ''                ,
372	exec_path                nvarchar2(255)  DEFAULT ''                ,
373	gsm_modem                nvarchar2(255)  DEFAULT ''                ,
374	username                 nvarchar2(255)  DEFAULT ''                ,
375	passwd                   nvarchar2(255)  DEFAULT ''                ,
376	status                   number(10)      DEFAULT '0'               NOT NULL,
377	smtp_port                number(10)      DEFAULT '25'              NOT NULL,
378	smtp_security            number(10)      DEFAULT '0'               NOT NULL,
379	smtp_verify_peer         number(10)      DEFAULT '0'               NOT NULL,
380	smtp_verify_host         number(10)      DEFAULT '0'               NOT NULL,
381	smtp_authentication      number(10)      DEFAULT '0'               NOT NULL,
382	exec_params              nvarchar2(255)  DEFAULT ''                ,
383	PRIMARY KEY (mediatypeid)
384);
385CREATE UNIQUE INDEX media_type_1 ON media_type (description);
386CREATE TABLE usrgrp (
387	usrgrpid                 number(20)                                NOT NULL,
388	name                     nvarchar2(64)   DEFAULT ''                ,
389	gui_access               number(10)      DEFAULT '0'               NOT NULL,
390	users_status             number(10)      DEFAULT '0'               NOT NULL,
391	debug_mode               number(10)      DEFAULT '0'               NOT NULL,
392	PRIMARY KEY (usrgrpid)
393);
394CREATE UNIQUE INDEX usrgrp_1 ON usrgrp (name);
395CREATE TABLE users_groups (
396	id                       number(20)                                NOT NULL,
397	usrgrpid                 number(20)                                NOT NULL,
398	userid                   number(20)                                NOT NULL,
399	PRIMARY KEY (id)
400);
401CREATE UNIQUE INDEX users_groups_1 ON users_groups (usrgrpid,userid);
402CREATE INDEX users_groups_2 ON users_groups (userid);
403CREATE TABLE scripts (
404	scriptid                 number(20)                                NOT NULL,
405	name                     nvarchar2(255)  DEFAULT ''                ,
406	command                  nvarchar2(255)  DEFAULT ''                ,
407	host_access              number(10)      DEFAULT '2'               NOT NULL,
408	usrgrpid                 number(20)                                NULL,
409	groupid                  number(20)                                NULL,
410	description              nvarchar2(2048) DEFAULT ''                ,
411	confirmation             nvarchar2(255)  DEFAULT ''                ,
412	type                     number(10)      DEFAULT '0'               NOT NULL,
413	execute_on               number(10)      DEFAULT '1'               NOT NULL,
414	PRIMARY KEY (scriptid)
415);
416CREATE INDEX scripts_1 ON scripts (usrgrpid);
417CREATE INDEX scripts_2 ON scripts (groupid);
418CREATE UNIQUE INDEX scripts_3 ON scripts (name);
419CREATE TABLE actions (
420	actionid                 number(20)                                NOT NULL,
421	name                     nvarchar2(255)  DEFAULT ''                ,
422	eventsource              number(10)      DEFAULT '0'               NOT NULL,
423	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
424	status                   number(10)      DEFAULT '0'               NOT NULL,
425	esc_period               number(10)      DEFAULT '0'               NOT NULL,
426	def_shortdata            nvarchar2(255)  DEFAULT ''                ,
427	def_longdata             nvarchar2(2048) DEFAULT ''                ,
428	recovery_msg             number(10)      DEFAULT '0'               NOT NULL,
429	r_shortdata              nvarchar2(255)  DEFAULT ''                ,
430	r_longdata               nvarchar2(2048) DEFAULT ''                ,
431	formula                  nvarchar2(255)  DEFAULT ''                ,
432	PRIMARY KEY (actionid)
433);
434CREATE INDEX actions_1 ON actions (eventsource,status);
435CREATE UNIQUE INDEX actions_2 ON actions (name);
436CREATE TABLE operations (
437	operationid              number(20)                                NOT NULL,
438	actionid                 number(20)                                NOT NULL,
439	operationtype            number(10)      DEFAULT '0'               NOT NULL,
440	esc_period               number(10)      DEFAULT '0'               NOT NULL,
441	esc_step_from            number(10)      DEFAULT '1'               NOT NULL,
442	esc_step_to              number(10)      DEFAULT '1'               NOT NULL,
443	evaltype                 number(10)      DEFAULT '0'               NOT NULL,
444	PRIMARY KEY (operationid)
445);
446CREATE INDEX operations_1 ON operations (actionid);
447CREATE TABLE opmessage (
448	operationid              number(20)                                NOT NULL,
449	default_msg              number(10)      DEFAULT '0'               NOT NULL,
450	subject                  nvarchar2(255)  DEFAULT ''                ,
451	message                  nvarchar2(2048) DEFAULT ''                ,
452	mediatypeid              number(20)                                NULL,
453	PRIMARY KEY (operationid)
454);
455CREATE INDEX opmessage_1 ON opmessage (mediatypeid);
456CREATE TABLE opmessage_grp (
457	opmessage_grpid          number(20)                                NOT NULL,
458	operationid              number(20)                                NOT NULL,
459	usrgrpid                 number(20)                                NOT NULL,
460	PRIMARY KEY (opmessage_grpid)
461);
462CREATE UNIQUE INDEX opmessage_grp_1 ON opmessage_grp (operationid,usrgrpid);
463CREATE INDEX opmessage_grp_2 ON opmessage_grp (usrgrpid);
464CREATE TABLE opmessage_usr (
465	opmessage_usrid          number(20)                                NOT NULL,
466	operationid              number(20)                                NOT NULL,
467	userid                   number(20)                                NOT NULL,
468	PRIMARY KEY (opmessage_usrid)
469);
470CREATE UNIQUE INDEX opmessage_usr_1 ON opmessage_usr (operationid,userid);
471CREATE INDEX opmessage_usr_2 ON opmessage_usr (userid);
472CREATE TABLE opcommand (
473	operationid              number(20)                                NOT NULL,
474	type                     number(10)      DEFAULT '0'               NOT NULL,
475	scriptid                 number(20)                                NULL,
476	execute_on               number(10)      DEFAULT '0'               NOT NULL,
477	port                     nvarchar2(64)   DEFAULT ''                ,
478	authtype                 number(10)      DEFAULT '0'               NOT NULL,
479	username                 nvarchar2(64)   DEFAULT ''                ,
480	password                 nvarchar2(64)   DEFAULT ''                ,
481	publickey                nvarchar2(64)   DEFAULT ''                ,
482	privatekey               nvarchar2(64)   DEFAULT ''                ,
483	command                  nvarchar2(2048) DEFAULT ''                ,
484	PRIMARY KEY (operationid)
485);
486CREATE INDEX opcommand_1 ON opcommand (scriptid);
487CREATE TABLE opcommand_hst (
488	opcommand_hstid          number(20)                                NOT NULL,
489	operationid              number(20)                                NOT NULL,
490	hostid                   number(20)                                NULL,
491	PRIMARY KEY (opcommand_hstid)
492);
493CREATE INDEX opcommand_hst_1 ON opcommand_hst (operationid);
494CREATE INDEX opcommand_hst_2 ON opcommand_hst (hostid);
495CREATE TABLE opcommand_grp (
496	opcommand_grpid          number(20)                                NOT NULL,
497	operationid              number(20)                                NOT NULL,
498	groupid                  number(20)                                NOT NULL,
499	PRIMARY KEY (opcommand_grpid)
500);
501CREATE INDEX opcommand_grp_1 ON opcommand_grp (operationid);
502CREATE INDEX opcommand_grp_2 ON opcommand_grp (groupid);
503CREATE TABLE opgroup (
504	opgroupid                number(20)                                NOT NULL,
505	operationid              number(20)                                NOT NULL,
506	groupid                  number(20)                                NOT NULL,
507	PRIMARY KEY (opgroupid)
508);
509CREATE UNIQUE INDEX opgroup_1 ON opgroup (operationid,groupid);
510CREATE INDEX opgroup_2 ON opgroup (groupid);
511CREATE TABLE optemplate (
512	optemplateid             number(20)                                NOT NULL,
513	operationid              number(20)                                NOT NULL,
514	templateid               number(20)                                NOT NULL,
515	PRIMARY KEY (optemplateid)
516);
517CREATE UNIQUE INDEX optemplate_1 ON optemplate (operationid,templateid);
518CREATE INDEX optemplate_2 ON optemplate (templateid);
519CREATE TABLE opconditions (
520	opconditionid            number(20)                                NOT NULL,
521	operationid              number(20)                                NOT NULL,
522	conditiontype            number(10)      DEFAULT '0'               NOT NULL,
523	operator                 number(10)      DEFAULT '0'               NOT NULL,
524	value                    nvarchar2(255)  DEFAULT ''                ,
525	PRIMARY KEY (opconditionid)
526);
527CREATE INDEX opconditions_1 ON opconditions (operationid);
528CREATE TABLE conditions (
529	conditionid              number(20)                                NOT NULL,
530	actionid                 number(20)                                NOT NULL,
531	conditiontype            number(10)      DEFAULT '0'               NOT NULL,
532	operator                 number(10)      DEFAULT '0'               NOT NULL,
533	value                    nvarchar2(255)  DEFAULT ''                ,
534	PRIMARY KEY (conditionid)
535);
536CREATE INDEX conditions_1 ON conditions (actionid);
537CREATE TABLE config (
538	configid                 number(20)                                NOT NULL,
539	refresh_unsupported      number(10)      DEFAULT '0'               NOT NULL,
540	work_period              nvarchar2(100)  DEFAULT '1-5,00:00-24:00' ,
541	alert_usrgrpid           number(20)                                NULL,
542	event_ack_enable         number(10)      DEFAULT '1'               NOT NULL,
543	event_expire             number(10)      DEFAULT '7'               NOT NULL,
544	event_show_max           number(10)      DEFAULT '100'             NOT NULL,
545	default_theme            nvarchar2(128)  DEFAULT 'blue-theme'      ,
546	authentication_type      number(10)      DEFAULT '0'               NOT NULL,
547	ldap_host                nvarchar2(255)  DEFAULT ''                ,
548	ldap_port                number(10)      DEFAULT 389               NOT NULL,
549	ldap_base_dn             nvarchar2(255)  DEFAULT ''                ,
550	ldap_bind_dn             nvarchar2(255)  DEFAULT ''                ,
551	ldap_bind_password       nvarchar2(128)  DEFAULT ''                ,
552	ldap_search_attribute    nvarchar2(128)  DEFAULT ''                ,
553	dropdown_first_entry     number(10)      DEFAULT '1'               NOT NULL,
554	dropdown_first_remember  number(10)      DEFAULT '1'               NOT NULL,
555	discovery_groupid        number(20)                                NOT NULL,
556	max_in_table             number(10)      DEFAULT '50'              NOT NULL,
557	search_limit             number(10)      DEFAULT '1000'            NOT NULL,
558	severity_color_0         nvarchar2(6)    DEFAULT '97AAB3'          ,
559	severity_color_1         nvarchar2(6)    DEFAULT '7499FF'          ,
560	severity_color_2         nvarchar2(6)    DEFAULT 'FFC859'          ,
561	severity_color_3         nvarchar2(6)    DEFAULT 'FFA059'          ,
562	severity_color_4         nvarchar2(6)    DEFAULT 'E97659'          ,
563	severity_color_5         nvarchar2(6)    DEFAULT 'E45959'          ,
564	severity_name_0          nvarchar2(32)   DEFAULT 'Not classified'  ,
565	severity_name_1          nvarchar2(32)   DEFAULT 'Information'     ,
566	severity_name_2          nvarchar2(32)   DEFAULT 'Warning'         ,
567	severity_name_3          nvarchar2(32)   DEFAULT 'Average'         ,
568	severity_name_4          nvarchar2(32)   DEFAULT 'High'            ,
569	severity_name_5          nvarchar2(32)   DEFAULT 'Disaster'        ,
570	ok_period                number(10)      DEFAULT '1800'            NOT NULL,
571	blink_period             number(10)      DEFAULT '1800'            NOT NULL,
572	problem_unack_color      nvarchar2(6)    DEFAULT 'DC0000'          ,
573	problem_ack_color        nvarchar2(6)    DEFAULT 'DC0000'          ,
574	ok_unack_color           nvarchar2(6)    DEFAULT '00AA00'          ,
575	ok_ack_color             nvarchar2(6)    DEFAULT '00AA00'          ,
576	problem_unack_style      number(10)      DEFAULT '1'               NOT NULL,
577	problem_ack_style        number(10)      DEFAULT '1'               NOT NULL,
578	ok_unack_style           number(10)      DEFAULT '1'               NOT NULL,
579	ok_ack_style             number(10)      DEFAULT '1'               NOT NULL,
580	snmptrap_logging         number(10)      DEFAULT '1'               NOT NULL,
581	server_check_interval    number(10)      DEFAULT '10'              NOT NULL,
582	hk_events_mode           number(10)      DEFAULT '1'               NOT NULL,
583	hk_events_trigger        number(10)      DEFAULT '365'             NOT NULL,
584	hk_events_internal       number(10)      DEFAULT '365'             NOT NULL,
585	hk_events_discovery      number(10)      DEFAULT '365'             NOT NULL,
586	hk_events_autoreg        number(10)      DEFAULT '365'             NOT NULL,
587	hk_services_mode         number(10)      DEFAULT '1'               NOT NULL,
588	hk_services              number(10)      DEFAULT '365'             NOT NULL,
589	hk_audit_mode            number(10)      DEFAULT '1'               NOT NULL,
590	hk_audit                 number(10)      DEFAULT '365'             NOT NULL,
591	hk_sessions_mode         number(10)      DEFAULT '1'               NOT NULL,
592	hk_sessions              number(10)      DEFAULT '365'             NOT NULL,
593	hk_history_mode          number(10)      DEFAULT '1'               NOT NULL,
594	hk_history_global        number(10)      DEFAULT '0'               NOT NULL,
595	hk_history               number(10)      DEFAULT '90'              NOT NULL,
596	hk_trends_mode           number(10)      DEFAULT '1'               NOT NULL,
597	hk_trends_global         number(10)      DEFAULT '0'               NOT NULL,
598	hk_trends                number(10)      DEFAULT '365'             NOT NULL,
599	default_inventory_mode   number(10)      DEFAULT '-1'              NOT NULL,
600	PRIMARY KEY (configid)
601);
602CREATE INDEX config_1 ON config (alert_usrgrpid);
603CREATE INDEX config_2 ON config (discovery_groupid);
604CREATE TABLE triggers (
605	triggerid                number(20)                                NOT NULL,
606	expression               nvarchar2(2048) DEFAULT ''                ,
607	description              nvarchar2(255)  DEFAULT ''                ,
608	url                      nvarchar2(255)  DEFAULT ''                ,
609	status                   number(10)      DEFAULT '0'               NOT NULL,
610	value                    number(10)      DEFAULT '0'               NOT NULL,
611	priority                 number(10)      DEFAULT '0'               NOT NULL,
612	lastchange               number(10)      DEFAULT '0'               NOT NULL,
613	comments                 nvarchar2(2048) DEFAULT ''                ,
614	error                    nvarchar2(128)  DEFAULT ''                ,
615	templateid               number(20)                                NULL,
616	type                     number(10)      DEFAULT '0'               NOT NULL,
617	state                    number(10)      DEFAULT '0'               NOT NULL,
618	flags                    number(10)      DEFAULT '0'               NOT NULL,
619	PRIMARY KEY (triggerid)
620);
621CREATE INDEX triggers_1 ON triggers (status);
622CREATE INDEX triggers_2 ON triggers (value,lastchange);
623CREATE INDEX triggers_3 ON triggers (templateid);
624CREATE TABLE trigger_depends (
625	triggerdepid             number(20)                                NOT NULL,
626	triggerid_down           number(20)                                NOT NULL,
627	triggerid_up             number(20)                                NOT NULL,
628	PRIMARY KEY (triggerdepid)
629);
630CREATE UNIQUE INDEX trigger_depends_1 ON trigger_depends (triggerid_down,triggerid_up);
631CREATE INDEX trigger_depends_2 ON trigger_depends (triggerid_up);
632CREATE TABLE functions (
633	functionid               number(20)                                NOT NULL,
634	itemid                   number(20)                                NOT NULL,
635	triggerid                number(20)                                NOT NULL,
636	function                 nvarchar2(12)   DEFAULT ''                ,
637	parameter                nvarchar2(255)  DEFAULT '0'               ,
638	PRIMARY KEY (functionid)
639);
640CREATE INDEX functions_1 ON functions (triggerid);
641CREATE INDEX functions_2 ON functions (itemid,function,parameter);
642CREATE TABLE graphs (
643	graphid                  number(20)                                NOT NULL,
644	name                     nvarchar2(128)  DEFAULT ''                ,
645	width                    number(10)      DEFAULT '900'             NOT NULL,
646	height                   number(10)      DEFAULT '200'             NOT NULL,
647	yaxismin                 number(20,4)    DEFAULT '0'               NOT NULL,
648	yaxismax                 number(20,4)    DEFAULT '100'             NOT NULL,
649	templateid               number(20)                                NULL,
650	show_work_period         number(10)      DEFAULT '1'               NOT NULL,
651	show_triggers            number(10)      DEFAULT '1'               NOT NULL,
652	graphtype                number(10)      DEFAULT '0'               NOT NULL,
653	show_legend              number(10)      DEFAULT '1'               NOT NULL,
654	show_3d                  number(10)      DEFAULT '0'               NOT NULL,
655	percent_left             number(20,4)    DEFAULT '0'               NOT NULL,
656	percent_right            number(20,4)    DEFAULT '0'               NOT NULL,
657	ymin_type                number(10)      DEFAULT '0'               NOT NULL,
658	ymax_type                number(10)      DEFAULT '0'               NOT NULL,
659	ymin_itemid              number(20)                                NULL,
660	ymax_itemid              number(20)                                NULL,
661	flags                    number(10)      DEFAULT '0'               NOT NULL,
662	PRIMARY KEY (graphid)
663);
664CREATE INDEX graphs_1 ON graphs (name);
665CREATE INDEX graphs_2 ON graphs (templateid);
666CREATE INDEX graphs_3 ON graphs (ymin_itemid);
667CREATE INDEX graphs_4 ON graphs (ymax_itemid);
668CREATE TABLE graphs_items (
669	gitemid                  number(20)                                NOT NULL,
670	graphid                  number(20)                                NOT NULL,
671	itemid                   number(20)                                NOT NULL,
672	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
673	sortorder                number(10)      DEFAULT '0'               NOT NULL,
674	color                    nvarchar2(6)    DEFAULT '009600'          ,
675	yaxisside                number(10)      DEFAULT '0'               NOT NULL,
676	calc_fnc                 number(10)      DEFAULT '2'               NOT NULL,
677	type                     number(10)      DEFAULT '0'               NOT NULL,
678	PRIMARY KEY (gitemid)
679);
680CREATE INDEX graphs_items_1 ON graphs_items (itemid);
681CREATE INDEX graphs_items_2 ON graphs_items (graphid);
682CREATE TABLE graph_theme (
683	graphthemeid             number(20)                                NOT NULL,
684	theme                    nvarchar2(64)   DEFAULT ''                ,
685	backgroundcolor          nvarchar2(6)    DEFAULT ''                ,
686	graphcolor               nvarchar2(6)    DEFAULT ''                ,
687	gridcolor                nvarchar2(6)    DEFAULT ''                ,
688	maingridcolor            nvarchar2(6)    DEFAULT ''                ,
689	gridbordercolor          nvarchar2(6)    DEFAULT ''                ,
690	textcolor                nvarchar2(6)    DEFAULT ''                ,
691	highlightcolor           nvarchar2(6)    DEFAULT ''                ,
692	leftpercentilecolor      nvarchar2(6)    DEFAULT ''                ,
693	rightpercentilecolor     nvarchar2(6)    DEFAULT ''                ,
694	nonworktimecolor         nvarchar2(6)    DEFAULT ''                ,
695	PRIMARY KEY (graphthemeid)
696);
697CREATE UNIQUE INDEX graph_theme_1 ON graph_theme (theme);
698CREATE TABLE globalmacro (
699	globalmacroid            number(20)                                NOT NULL,
700	macro                    nvarchar2(255)  DEFAULT ''                ,
701	value                    nvarchar2(255)  DEFAULT ''                ,
702	PRIMARY KEY (globalmacroid)
703);
704CREATE UNIQUE INDEX globalmacro_1 ON globalmacro (macro);
705CREATE TABLE hostmacro (
706	hostmacroid              number(20)                                NOT NULL,
707	hostid                   number(20)                                NOT NULL,
708	macro                    nvarchar2(255)  DEFAULT ''                ,
709	value                    nvarchar2(255)  DEFAULT ''                ,
710	PRIMARY KEY (hostmacroid)
711);
712CREATE UNIQUE INDEX hostmacro_1 ON hostmacro (hostid,macro);
713CREATE TABLE hosts_groups (
714	hostgroupid              number(20)                                NOT NULL,
715	hostid                   number(20)                                NOT NULL,
716	groupid                  number(20)                                NOT NULL,
717	PRIMARY KEY (hostgroupid)
718);
719CREATE UNIQUE INDEX hosts_groups_1 ON hosts_groups (hostid,groupid);
720CREATE INDEX hosts_groups_2 ON hosts_groups (groupid);
721CREATE TABLE hosts_templates (
722	hosttemplateid           number(20)                                NOT NULL,
723	hostid                   number(20)                                NOT NULL,
724	templateid               number(20)                                NOT NULL,
725	PRIMARY KEY (hosttemplateid)
726);
727CREATE UNIQUE INDEX hosts_templates_1 ON hosts_templates (hostid,templateid);
728CREATE INDEX hosts_templates_2 ON hosts_templates (templateid);
729CREATE TABLE items_applications (
730	itemappid                number(20)                                NOT NULL,
731	applicationid            number(20)                                NOT NULL,
732	itemid                   number(20)                                NOT NULL,
733	PRIMARY KEY (itemappid)
734);
735CREATE UNIQUE INDEX items_applications_1 ON items_applications (applicationid,itemid);
736CREATE INDEX items_applications_2 ON items_applications (itemid);
737CREATE TABLE mappings (
738	mappingid                number(20)                                NOT NULL,
739	valuemapid               number(20)                                NOT NULL,
740	value                    nvarchar2(64)   DEFAULT ''                ,
741	newvalue                 nvarchar2(64)   DEFAULT ''                ,
742	PRIMARY KEY (mappingid)
743);
744CREATE INDEX mappings_1 ON mappings (valuemapid);
745CREATE TABLE media (
746	mediaid                  number(20)                                NOT NULL,
747	userid                   number(20)                                NOT NULL,
748	mediatypeid              number(20)                                NOT NULL,
749	sendto                   nvarchar2(100)  DEFAULT ''                ,
750	active                   number(10)      DEFAULT '0'               NOT NULL,
751	severity                 number(10)      DEFAULT '63'              NOT NULL,
752	period                   nvarchar2(100)  DEFAULT '1-7,00:00-24:00' ,
753	PRIMARY KEY (mediaid)
754);
755CREATE INDEX media_1 ON media (userid);
756CREATE INDEX media_2 ON media (mediatypeid);
757CREATE TABLE rights (
758	rightid                  number(20)                                NOT NULL,
759	groupid                  number(20)                                NOT NULL,
760	permission               number(10)      DEFAULT '0'               NOT NULL,
761	id                       number(20)                                NOT NULL,
762	PRIMARY KEY (rightid)
763);
764CREATE INDEX rights_1 ON rights (groupid);
765CREATE INDEX rights_2 ON rights (id);
766CREATE TABLE services (
767	serviceid                number(20)                                NOT NULL,
768	name                     nvarchar2(128)  DEFAULT ''                ,
769	status                   number(10)      DEFAULT '0'               NOT NULL,
770	algorithm                number(10)      DEFAULT '0'               NOT NULL,
771	triggerid                number(20)                                NULL,
772	showsla                  number(10)      DEFAULT '0'               NOT NULL,
773	goodsla                  number(20,4)    DEFAULT '99.9'            NOT NULL,
774	sortorder                number(10)      DEFAULT '0'               NOT NULL,
775	PRIMARY KEY (serviceid)
776);
777CREATE INDEX services_1 ON services (triggerid);
778CREATE TABLE services_links (
779	linkid                   number(20)                                NOT NULL,
780	serviceupid              number(20)                                NOT NULL,
781	servicedownid            number(20)                                NOT NULL,
782	soft                     number(10)      DEFAULT '0'               NOT NULL,
783	PRIMARY KEY (linkid)
784);
785CREATE INDEX services_links_1 ON services_links (servicedownid);
786CREATE UNIQUE INDEX services_links_2 ON services_links (serviceupid,servicedownid);
787CREATE TABLE services_times (
788	timeid                   number(20)                                NOT NULL,
789	serviceid                number(20)                                NOT NULL,
790	type                     number(10)      DEFAULT '0'               NOT NULL,
791	ts_from                  number(10)      DEFAULT '0'               NOT NULL,
792	ts_to                    number(10)      DEFAULT '0'               NOT NULL,
793	note                     nvarchar2(255)  DEFAULT ''                ,
794	PRIMARY KEY (timeid)
795);
796CREATE INDEX services_times_1 ON services_times (serviceid,type,ts_from,ts_to);
797CREATE TABLE icon_map (
798	iconmapid                number(20)                                NOT NULL,
799	name                     nvarchar2(64)   DEFAULT ''                ,
800	default_iconid           number(20)                                NOT NULL,
801	PRIMARY KEY (iconmapid)
802);
803CREATE UNIQUE INDEX icon_map_1 ON icon_map (name);
804CREATE INDEX icon_map_2 ON icon_map (default_iconid);
805CREATE TABLE icon_mapping (
806	iconmappingid            number(20)                                NOT NULL,
807	iconmapid                number(20)                                NOT NULL,
808	iconid                   number(20)                                NOT NULL,
809	inventory_link           number(10)      DEFAULT '0'               NOT NULL,
810	expression               nvarchar2(64)   DEFAULT ''                ,
811	sortorder                number(10)      DEFAULT '0'               NOT NULL,
812	PRIMARY KEY (iconmappingid)
813);
814CREATE INDEX icon_mapping_1 ON icon_mapping (iconmapid);
815CREATE INDEX icon_mapping_2 ON icon_mapping (iconid);
816CREATE TABLE sysmaps (
817	sysmapid                 number(20)                                NOT NULL,
818	name                     nvarchar2(128)  DEFAULT ''                ,
819	width                    number(10)      DEFAULT '600'             NOT NULL,
820	height                   number(10)      DEFAULT '400'             NOT NULL,
821	backgroundid             number(20)                                NULL,
822	label_type               number(10)      DEFAULT '2'               NOT NULL,
823	label_location           number(10)      DEFAULT '0'               NOT NULL,
824	highlight                number(10)      DEFAULT '1'               NOT NULL,
825	expandproblem            number(10)      DEFAULT '1'               NOT NULL,
826	markelements             number(10)      DEFAULT '0'               NOT NULL,
827	show_unack               number(10)      DEFAULT '0'               NOT NULL,
828	grid_size                number(10)      DEFAULT '50'              NOT NULL,
829	grid_show                number(10)      DEFAULT '1'               NOT NULL,
830	grid_align               number(10)      DEFAULT '1'               NOT NULL,
831	label_format             number(10)      DEFAULT '0'               NOT NULL,
832	label_type_host          number(10)      DEFAULT '2'               NOT NULL,
833	label_type_hostgroup     number(10)      DEFAULT '2'               NOT NULL,
834	label_type_trigger       number(10)      DEFAULT '2'               NOT NULL,
835	label_type_map           number(10)      DEFAULT '2'               NOT NULL,
836	label_type_image         number(10)      DEFAULT '2'               NOT NULL,
837	label_string_host        nvarchar2(255)  DEFAULT ''                ,
838	label_string_hostgroup   nvarchar2(255)  DEFAULT ''                ,
839	label_string_trigger     nvarchar2(255)  DEFAULT ''                ,
840	label_string_map         nvarchar2(255)  DEFAULT ''                ,
841	label_string_image       nvarchar2(255)  DEFAULT ''                ,
842	iconmapid                number(20)                                NULL,
843	expand_macros            number(10)      DEFAULT '0'               NOT NULL,
844	severity_min             number(10)      DEFAULT '0'               NOT NULL,
845	userid                   number(20)                                NOT NULL,
846	private                  number(10)      DEFAULT '1'               NOT NULL,
847	PRIMARY KEY (sysmapid)
848);
849CREATE UNIQUE INDEX sysmaps_1 ON sysmaps (name);
850CREATE INDEX sysmaps_2 ON sysmaps (backgroundid);
851CREATE INDEX sysmaps_3 ON sysmaps (iconmapid);
852CREATE TABLE sysmaps_elements (
853	selementid               number(20)                                NOT NULL,
854	sysmapid                 number(20)                                NOT NULL,
855	elementid                number(20)      DEFAULT '0'               NOT NULL,
856	elementtype              number(10)      DEFAULT '0'               NOT NULL,
857	iconid_off               number(20)                                NULL,
858	iconid_on                number(20)                                NULL,
859	label                    nvarchar2(2048) DEFAULT ''                ,
860	label_location           number(10)      DEFAULT '-1'              NOT NULL,
861	x                        number(10)      DEFAULT '0'               NOT NULL,
862	y                        number(10)      DEFAULT '0'               NOT NULL,
863	iconid_disabled          number(20)                                NULL,
864	iconid_maintenance       number(20)                                NULL,
865	elementsubtype           number(10)      DEFAULT '0'               NOT NULL,
866	areatype                 number(10)      DEFAULT '0'               NOT NULL,
867	width                    number(10)      DEFAULT '200'             NOT NULL,
868	height                   number(10)      DEFAULT '200'             NOT NULL,
869	viewtype                 number(10)      DEFAULT '0'               NOT NULL,
870	use_iconmap              number(10)      DEFAULT '1'               NOT NULL,
871	application              nvarchar2(255)  DEFAULT ''                ,
872	PRIMARY KEY (selementid)
873);
874CREATE INDEX sysmaps_elements_1 ON sysmaps_elements (sysmapid);
875CREATE INDEX sysmaps_elements_2 ON sysmaps_elements (iconid_off);
876CREATE INDEX sysmaps_elements_3 ON sysmaps_elements (iconid_on);
877CREATE INDEX sysmaps_elements_4 ON sysmaps_elements (iconid_disabled);
878CREATE INDEX sysmaps_elements_5 ON sysmaps_elements (iconid_maintenance);
879CREATE TABLE sysmaps_links (
880	linkid                   number(20)                                NOT NULL,
881	sysmapid                 number(20)                                NOT NULL,
882	selementid1              number(20)                                NOT NULL,
883	selementid2              number(20)                                NOT NULL,
884	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
885	color                    nvarchar2(6)    DEFAULT '000000'          ,
886	label                    nvarchar2(2048) DEFAULT ''                ,
887	PRIMARY KEY (linkid)
888);
889CREATE INDEX sysmaps_links_1 ON sysmaps_links (sysmapid);
890CREATE INDEX sysmaps_links_2 ON sysmaps_links (selementid1);
891CREATE INDEX sysmaps_links_3 ON sysmaps_links (selementid2);
892CREATE TABLE sysmaps_link_triggers (
893	linktriggerid            number(20)                                NOT NULL,
894	linkid                   number(20)                                NOT NULL,
895	triggerid                number(20)                                NOT NULL,
896	drawtype                 number(10)      DEFAULT '0'               NOT NULL,
897	color                    nvarchar2(6)    DEFAULT '000000'          ,
898	PRIMARY KEY (linktriggerid)
899);
900CREATE UNIQUE INDEX sysmaps_link_triggers_1 ON sysmaps_link_triggers (linkid,triggerid);
901CREATE INDEX sysmaps_link_triggers_2 ON sysmaps_link_triggers (triggerid);
902CREATE TABLE sysmap_element_url (
903	sysmapelementurlid       number(20)                                NOT NULL,
904	selementid               number(20)                                NOT NULL,
905	name                     nvarchar2(255)                            ,
906	url                      nvarchar2(255)  DEFAULT ''                ,
907	PRIMARY KEY (sysmapelementurlid)
908);
909CREATE UNIQUE INDEX sysmap_element_url_1 ON sysmap_element_url (selementid,name);
910CREATE TABLE sysmap_url (
911	sysmapurlid              number(20)                                NOT NULL,
912	sysmapid                 number(20)                                NOT NULL,
913	name                     nvarchar2(255)                            ,
914	url                      nvarchar2(255)  DEFAULT ''                ,
915	elementtype              number(10)      DEFAULT '0'               NOT NULL,
916	PRIMARY KEY (sysmapurlid)
917);
918CREATE UNIQUE INDEX sysmap_url_1 ON sysmap_url (sysmapid,name);
919CREATE TABLE sysmap_user (
920	sysmapuserid             number(20)                                NOT NULL,
921	sysmapid                 number(20)                                NOT NULL,
922	userid                   number(20)                                NOT NULL,
923	permission               number(10)      DEFAULT '2'               NOT NULL,
924	PRIMARY KEY (sysmapuserid)
925);
926CREATE UNIQUE INDEX sysmap_user_1 ON sysmap_user (sysmapid,userid);
927CREATE TABLE sysmap_usrgrp (
928	sysmapusrgrpid           number(20)                                NOT NULL,
929	sysmapid                 number(20)                                NOT NULL,
930	usrgrpid                 number(20)                                NOT NULL,
931	permission               number(10)      DEFAULT '2'               NOT NULL,
932	PRIMARY KEY (sysmapusrgrpid)
933);
934CREATE UNIQUE INDEX sysmap_usrgrp_1 ON sysmap_usrgrp (sysmapid,usrgrpid);
935CREATE TABLE maintenances_hosts (
936	maintenance_hostid       number(20)                                NOT NULL,
937	maintenanceid            number(20)                                NOT NULL,
938	hostid                   number(20)                                NOT NULL,
939	PRIMARY KEY (maintenance_hostid)
940);
941CREATE UNIQUE INDEX maintenances_hosts_1 ON maintenances_hosts (maintenanceid,hostid);
942CREATE INDEX maintenances_hosts_2 ON maintenances_hosts (hostid);
943CREATE TABLE maintenances_groups (
944	maintenance_groupid      number(20)                                NOT NULL,
945	maintenanceid            number(20)                                NOT NULL,
946	groupid                  number(20)                                NOT NULL,
947	PRIMARY KEY (maintenance_groupid)
948);
949CREATE UNIQUE INDEX maintenances_groups_1 ON maintenances_groups (maintenanceid,groupid);
950CREATE INDEX maintenances_groups_2 ON maintenances_groups (groupid);
951CREATE TABLE timeperiods (
952	timeperiodid             number(20)                                NOT NULL,
953	timeperiod_type          number(10)      DEFAULT '0'               NOT NULL,
954	every                    number(10)      DEFAULT '1'               NOT NULL,
955	month                    number(10)      DEFAULT '0'               NOT NULL,
956	dayofweek                number(10)      DEFAULT '0'               NOT NULL,
957	day                      number(10)      DEFAULT '0'               NOT NULL,
958	start_time               number(10)      DEFAULT '0'               NOT NULL,
959	period                   number(10)      DEFAULT '0'               NOT NULL,
960	start_date               number(10)      DEFAULT '0'               NOT NULL,
961	PRIMARY KEY (timeperiodid)
962);
963CREATE TABLE maintenances_windows (
964	maintenance_timeperiodid number(20)                                NOT NULL,
965	maintenanceid            number(20)                                NOT NULL,
966	timeperiodid             number(20)                                NOT NULL,
967	PRIMARY KEY (maintenance_timeperiodid)
968);
969CREATE UNIQUE INDEX maintenances_windows_1 ON maintenances_windows (maintenanceid,timeperiodid);
970CREATE INDEX maintenances_windows_2 ON maintenances_windows (timeperiodid);
971CREATE TABLE regexps (
972	regexpid                 number(20)                                NOT NULL,
973	name                     nvarchar2(128)  DEFAULT ''                ,
974	test_string              nvarchar2(2048) DEFAULT ''                ,
975	PRIMARY KEY (regexpid)
976);
977CREATE UNIQUE INDEX regexps_1 ON regexps (name);
978CREATE TABLE expressions (
979	expressionid             number(20)                                NOT NULL,
980	regexpid                 number(20)                                NOT NULL,
981	expression               nvarchar2(255)  DEFAULT ''                ,
982	expression_type          number(10)      DEFAULT '0'               NOT NULL,
983	exp_delimiter            nvarchar2(1)    DEFAULT ''                ,
984	case_sensitive           number(10)      DEFAULT '0'               NOT NULL,
985	PRIMARY KEY (expressionid)
986);
987CREATE INDEX expressions_1 ON expressions (regexpid);
988CREATE TABLE ids (
989	table_name               nvarchar2(64)   DEFAULT ''                ,
990	field_name               nvarchar2(64)   DEFAULT ''                ,
991	nextid                   number(20)                                NOT NULL,
992	PRIMARY KEY (table_name,field_name)
993);
994CREATE TABLE alerts (
995	alertid                  number(20)                                NOT NULL,
996	actionid                 number(20)                                NOT NULL,
997	eventid                  number(20)                                NOT NULL,
998	userid                   number(20)                                NULL,
999	clock                    number(10)      DEFAULT '0'               NOT NULL,
1000	mediatypeid              number(20)                                NULL,
1001	sendto                   nvarchar2(100)  DEFAULT ''                ,
1002	subject                  nvarchar2(255)  DEFAULT ''                ,
1003	message                  nclob           DEFAULT ''                ,
1004	status                   number(10)      DEFAULT '0'               NOT NULL,
1005	retries                  number(10)      DEFAULT '0'               NOT NULL,
1006	error                    nvarchar2(128)  DEFAULT ''                ,
1007	esc_step                 number(10)      DEFAULT '0'               NOT NULL,
1008	alerttype                number(10)      DEFAULT '0'               NOT NULL,
1009	PRIMARY KEY (alertid)
1010);
1011CREATE INDEX alerts_1 ON alerts (actionid);
1012CREATE INDEX alerts_2 ON alerts (clock);
1013CREATE INDEX alerts_3 ON alerts (eventid);
1014CREATE INDEX alerts_4 ON alerts (status,retries);
1015CREATE INDEX alerts_5 ON alerts (mediatypeid);
1016CREATE INDEX alerts_6 ON alerts (userid);
1017CREATE TABLE history (
1018	itemid                   number(20)                                NOT NULL,
1019	clock                    number(10)      DEFAULT '0'               NOT NULL,
1020	value                    number(20,4)    DEFAULT '0.0000'          NOT NULL,
1021	ns                       number(10)      DEFAULT '0'               NOT NULL
1022);
1023CREATE INDEX history_1 ON history (itemid,clock);
1024CREATE TABLE history_uint (
1025	itemid                   number(20)                                NOT NULL,
1026	clock                    number(10)      DEFAULT '0'               NOT NULL,
1027	value                    number(20)      DEFAULT '0'               NOT NULL,
1028	ns                       number(10)      DEFAULT '0'               NOT NULL
1029);
1030CREATE INDEX history_uint_1 ON history_uint (itemid,clock);
1031CREATE TABLE history_str (
1032	itemid                   number(20)                                NOT NULL,
1033	clock                    number(10)      DEFAULT '0'               NOT NULL,
1034	value                    nvarchar2(255)  DEFAULT ''                ,
1035	ns                       number(10)      DEFAULT '0'               NOT NULL
1036);
1037CREATE INDEX history_str_1 ON history_str (itemid,clock);
1038CREATE TABLE history_log (
1039	id                       number(20)                                NOT NULL,
1040	itemid                   number(20)                                NOT NULL,
1041	clock                    number(10)      DEFAULT '0'               NOT NULL,
1042	timestamp                number(10)      DEFAULT '0'               NOT NULL,
1043	source                   nvarchar2(64)   DEFAULT ''                ,
1044	severity                 number(10)      DEFAULT '0'               NOT NULL,
1045	value                    nclob           DEFAULT ''                ,
1046	logeventid               number(10)      DEFAULT '0'               NOT NULL,
1047	ns                       number(10)      DEFAULT '0'               NOT NULL,
1048	PRIMARY KEY (id)
1049);
1050CREATE INDEX history_log_1 ON history_log (itemid,clock);
1051CREATE UNIQUE INDEX history_log_2 ON history_log (itemid,id);
1052CREATE TABLE history_text (
1053	id                       number(20)                                NOT NULL,
1054	itemid                   number(20)                                NOT NULL,
1055	clock                    number(10)      DEFAULT '0'               NOT NULL,
1056	value                    nclob           DEFAULT ''                ,
1057	ns                       number(10)      DEFAULT '0'               NOT NULL,
1058	PRIMARY KEY (id)
1059);
1060CREATE INDEX history_text_1 ON history_text (itemid,clock);
1061CREATE UNIQUE INDEX history_text_2 ON history_text (itemid,id);
1062CREATE TABLE proxy_history (
1063	id                       number(20)                                NOT NULL,
1064	itemid                   number(20)                                NOT NULL,
1065	clock                    number(10)      DEFAULT '0'               NOT NULL,
1066	timestamp                number(10)      DEFAULT '0'               NOT NULL,
1067	source                   nvarchar2(64)   DEFAULT ''                ,
1068	severity                 number(10)      DEFAULT '0'               NOT NULL,
1069	value                    nclob           DEFAULT ''                ,
1070	logeventid               number(10)      DEFAULT '0'               NOT NULL,
1071	ns                       number(10)      DEFAULT '0'               NOT NULL,
1072	state                    number(10)      DEFAULT '0'               NOT NULL,
1073	lastlogsize              number(20)      DEFAULT '0'               NOT NULL,
1074	mtime                    number(10)      DEFAULT '0'               NOT NULL,
1075	flags                    number(10)      DEFAULT '0'               NOT NULL,
1076	PRIMARY KEY (id)
1077);
1078CREATE INDEX proxy_history_1 ON proxy_history (clock);
1079CREATE TABLE proxy_dhistory (
1080	id                       number(20)                                NOT NULL,
1081	clock                    number(10)      DEFAULT '0'               NOT NULL,
1082	druleid                  number(20)                                NOT NULL,
1083	type                     number(10)      DEFAULT '0'               NOT NULL,
1084	ip                       nvarchar2(39)   DEFAULT ''                ,
1085	port                     number(10)      DEFAULT '0'               NOT NULL,
1086	key_                     nvarchar2(255)  DEFAULT ''                ,
1087	value                    nvarchar2(255)  DEFAULT ''                ,
1088	status                   number(10)      DEFAULT '0'               NOT NULL,
1089	dcheckid                 number(20)                                NULL,
1090	dns                      nvarchar2(64)   DEFAULT ''                ,
1091	PRIMARY KEY (id)
1092);
1093CREATE INDEX proxy_dhistory_1 ON proxy_dhistory (clock);
1094CREATE TABLE events (
1095	eventid                  number(20)                                NOT NULL,
1096	source                   number(10)      DEFAULT '0'               NOT NULL,
1097	object                   number(10)      DEFAULT '0'               NOT NULL,
1098	objectid                 number(20)      DEFAULT '0'               NOT NULL,
1099	clock                    number(10)      DEFAULT '0'               NOT NULL,
1100	value                    number(10)      DEFAULT '0'               NOT NULL,
1101	acknowledged             number(10)      DEFAULT '0'               NOT NULL,
1102	ns                       number(10)      DEFAULT '0'               NOT NULL,
1103	PRIMARY KEY (eventid)
1104);
1105CREATE INDEX events_1 ON events (source,object,objectid,clock);
1106CREATE INDEX events_2 ON events (source,object,clock);
1107CREATE TABLE trends (
1108	itemid                   number(20)                                NOT NULL,
1109	clock                    number(10)      DEFAULT '0'               NOT NULL,
1110	num                      number(10)      DEFAULT '0'               NOT NULL,
1111	value_min                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1112	value_avg                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1113	value_max                number(20,4)    DEFAULT '0.0000'          NOT NULL,
1114	PRIMARY KEY (itemid,clock)
1115);
1116CREATE TABLE trends_uint (
1117	itemid                   number(20)                                NOT NULL,
1118	clock                    number(10)      DEFAULT '0'               NOT NULL,
1119	num                      number(10)      DEFAULT '0'               NOT NULL,
1120	value_min                number(20)      DEFAULT '0'               NOT NULL,
1121	value_avg                number(20)      DEFAULT '0'               NOT NULL,
1122	value_max                number(20)      DEFAULT '0'               NOT NULL,
1123	PRIMARY KEY (itemid,clock)
1124);
1125CREATE TABLE acknowledges (
1126	acknowledgeid            number(20)                                NOT NULL,
1127	userid                   number(20)                                NOT NULL,
1128	eventid                  number(20)                                NOT NULL,
1129	clock                    number(10)      DEFAULT '0'               NOT NULL,
1130	message                  nvarchar2(255)  DEFAULT ''                ,
1131	PRIMARY KEY (acknowledgeid)
1132);
1133CREATE INDEX acknowledges_1 ON acknowledges (userid);
1134CREATE INDEX acknowledges_2 ON acknowledges (eventid);
1135CREATE INDEX acknowledges_3 ON acknowledges (clock);
1136CREATE TABLE auditlog (
1137	auditid                  number(20)                                NOT NULL,
1138	userid                   number(20)                                NOT NULL,
1139	clock                    number(10)      DEFAULT '0'               NOT NULL,
1140	action                   number(10)      DEFAULT '0'               NOT NULL,
1141	resourcetype             number(10)      DEFAULT '0'               NOT NULL,
1142	details                  nvarchar2(128)  DEFAULT '0'               ,
1143	ip                       nvarchar2(39)   DEFAULT ''                ,
1144	resourceid               number(20)      DEFAULT '0'               NOT NULL,
1145	resourcename             nvarchar2(255)  DEFAULT ''                ,
1146	PRIMARY KEY (auditid)
1147);
1148CREATE INDEX auditlog_1 ON auditlog (userid,clock);
1149CREATE INDEX auditlog_2 ON auditlog (clock);
1150CREATE TABLE auditlog_details (
1151	auditdetailid            number(20)                                NOT NULL,
1152	auditid                  number(20)                                NOT NULL,
1153	table_name               nvarchar2(64)   DEFAULT ''                ,
1154	field_name               nvarchar2(64)   DEFAULT ''                ,
1155	oldvalue                 nvarchar2(2048) DEFAULT ''                ,
1156	newvalue                 nvarchar2(2048) DEFAULT ''                ,
1157	PRIMARY KEY (auditdetailid)
1158);
1159CREATE INDEX auditlog_details_1 ON auditlog_details (auditid);
1160CREATE TABLE service_alarms (
1161	servicealarmid           number(20)                                NOT NULL,
1162	serviceid                number(20)                                NOT NULL,
1163	clock                    number(10)      DEFAULT '0'               NOT NULL,
1164	value                    number(10)      DEFAULT '0'               NOT NULL,
1165	PRIMARY KEY (servicealarmid)
1166);
1167CREATE INDEX service_alarms_1 ON service_alarms (serviceid,clock);
1168CREATE INDEX service_alarms_2 ON service_alarms (clock);
1169CREATE TABLE autoreg_host (
1170	autoreg_hostid           number(20)                                NOT NULL,
1171	proxy_hostid             number(20)                                NULL,
1172	host                     nvarchar2(64)   DEFAULT ''                ,
1173	listen_ip                nvarchar2(39)   DEFAULT ''                ,
1174	listen_port              number(10)      DEFAULT '0'               NOT NULL,
1175	listen_dns               nvarchar2(64)   DEFAULT ''                ,
1176	host_metadata            nvarchar2(255)  DEFAULT ''                ,
1177	PRIMARY KEY (autoreg_hostid)
1178);
1179CREATE INDEX autoreg_host_1 ON autoreg_host (proxy_hostid,host);
1180CREATE TABLE proxy_autoreg_host (
1181	id                       number(20)                                NOT NULL,
1182	clock                    number(10)      DEFAULT '0'               NOT NULL,
1183	host                     nvarchar2(64)   DEFAULT ''                ,
1184	listen_ip                nvarchar2(39)   DEFAULT ''                ,
1185	listen_port              number(10)      DEFAULT '0'               NOT NULL,
1186	listen_dns               nvarchar2(64)   DEFAULT ''                ,
1187	host_metadata            nvarchar2(255)  DEFAULT ''                ,
1188	PRIMARY KEY (id)
1189);
1190CREATE INDEX proxy_autoreg_host_1 ON proxy_autoreg_host (clock);
1191CREATE TABLE dhosts (
1192	dhostid                  number(20)                                NOT NULL,
1193	druleid                  number(20)                                NOT NULL,
1194	status                   number(10)      DEFAULT '0'               NOT NULL,
1195	lastup                   number(10)      DEFAULT '0'               NOT NULL,
1196	lastdown                 number(10)      DEFAULT '0'               NOT NULL,
1197	PRIMARY KEY (dhostid)
1198);
1199CREATE INDEX dhosts_1 ON dhosts (druleid);
1200CREATE TABLE dservices (
1201	dserviceid               number(20)                                NOT NULL,
1202	dhostid                  number(20)                                NOT NULL,
1203	type                     number(10)      DEFAULT '0'               NOT NULL,
1204	key_                     nvarchar2(255)  DEFAULT ''                ,
1205	value                    nvarchar2(255)  DEFAULT ''                ,
1206	port                     number(10)      DEFAULT '0'               NOT NULL,
1207	status                   number(10)      DEFAULT '0'               NOT NULL,
1208	lastup                   number(10)      DEFAULT '0'               NOT NULL,
1209	lastdown                 number(10)      DEFAULT '0'               NOT NULL,
1210	dcheckid                 number(20)                                NOT NULL,
1211	ip                       nvarchar2(39)   DEFAULT ''                ,
1212	dns                      nvarchar2(64)   DEFAULT ''                ,
1213	PRIMARY KEY (dserviceid)
1214);
1215CREATE UNIQUE INDEX dservices_1 ON dservices (dcheckid,type,key_,ip,port);
1216CREATE INDEX dservices_2 ON dservices (dhostid);
1217CREATE TABLE escalations (
1218	escalationid             number(20)                                NOT NULL,
1219	actionid                 number(20)                                NOT NULL,
1220	triggerid                number(20)                                NULL,
1221	eventid                  number(20)                                NULL,
1222	r_eventid                number(20)                                NULL,
1223	nextcheck                number(10)      DEFAULT '0'               NOT NULL,
1224	esc_step                 number(10)      DEFAULT '0'               NOT NULL,
1225	status                   number(10)      DEFAULT '0'               NOT NULL,
1226	itemid                   number(20)                                NULL,
1227	PRIMARY KEY (escalationid)
1228);
1229CREATE UNIQUE INDEX escalations_1 ON escalations (actionid,triggerid,itemid,escalationid);
1230CREATE TABLE globalvars (
1231	globalvarid              number(20)                                NOT NULL,
1232	snmp_lastsize            number(10)      DEFAULT '0'               NOT NULL,
1233	PRIMARY KEY (globalvarid)
1234);
1235CREATE TABLE graph_discovery (
1236	graphid                  number(20)                                NOT NULL,
1237	parent_graphid           number(20)                                NOT NULL,
1238	PRIMARY KEY (graphid)
1239);
1240CREATE INDEX graph_discovery_1 ON graph_discovery (parent_graphid);
1241CREATE TABLE host_inventory (
1242	hostid                   number(20)                                NOT NULL,
1243	inventory_mode           number(10)      DEFAULT '0'               NOT NULL,
1244	type                     nvarchar2(64)   DEFAULT ''                ,
1245	type_full                nvarchar2(64)   DEFAULT ''                ,
1246	name                     nvarchar2(64)   DEFAULT ''                ,
1247	alias                    nvarchar2(64)   DEFAULT ''                ,
1248	os                       nvarchar2(64)   DEFAULT ''                ,
1249	os_full                  nvarchar2(255)  DEFAULT ''                ,
1250	os_short                 nvarchar2(64)   DEFAULT ''                ,
1251	serialno_a               nvarchar2(64)   DEFAULT ''                ,
1252	serialno_b               nvarchar2(64)   DEFAULT ''                ,
1253	tag                      nvarchar2(64)   DEFAULT ''                ,
1254	asset_tag                nvarchar2(64)   DEFAULT ''                ,
1255	macaddress_a             nvarchar2(64)   DEFAULT ''                ,
1256	macaddress_b             nvarchar2(64)   DEFAULT ''                ,
1257	hardware                 nvarchar2(255)  DEFAULT ''                ,
1258	hardware_full            nvarchar2(2048) DEFAULT ''                ,
1259	software                 nvarchar2(255)  DEFAULT ''                ,
1260	software_full            nvarchar2(2048) DEFAULT ''                ,
1261	software_app_a           nvarchar2(64)   DEFAULT ''                ,
1262	software_app_b           nvarchar2(64)   DEFAULT ''                ,
1263	software_app_c           nvarchar2(64)   DEFAULT ''                ,
1264	software_app_d           nvarchar2(64)   DEFAULT ''                ,
1265	software_app_e           nvarchar2(64)   DEFAULT ''                ,
1266	contact                  nvarchar2(2048) DEFAULT ''                ,
1267	location                 nvarchar2(2048) DEFAULT ''                ,
1268	location_lat             nvarchar2(16)   DEFAULT ''                ,
1269	location_lon             nvarchar2(16)   DEFAULT ''                ,
1270	notes                    nvarchar2(2048) DEFAULT ''                ,
1271	chassis                  nvarchar2(64)   DEFAULT ''                ,
1272	model                    nvarchar2(64)   DEFAULT ''                ,
1273	hw_arch                  nvarchar2(32)   DEFAULT ''                ,
1274	vendor                   nvarchar2(64)   DEFAULT ''                ,
1275	contract_number          nvarchar2(64)   DEFAULT ''                ,
1276	installer_name           nvarchar2(64)   DEFAULT ''                ,
1277	deployment_status        nvarchar2(64)   DEFAULT ''                ,
1278	url_a                    nvarchar2(255)  DEFAULT ''                ,
1279	url_b                    nvarchar2(255)  DEFAULT ''                ,
1280	url_c                    nvarchar2(255)  DEFAULT ''                ,
1281	host_networks            nvarchar2(2048) DEFAULT ''                ,
1282	host_netmask             nvarchar2(39)   DEFAULT ''                ,
1283	host_router              nvarchar2(39)   DEFAULT ''                ,
1284	oob_ip                   nvarchar2(39)   DEFAULT ''                ,
1285	oob_netmask              nvarchar2(39)   DEFAULT ''                ,
1286	oob_router               nvarchar2(39)   DEFAULT ''                ,
1287	date_hw_purchase         nvarchar2(64)   DEFAULT ''                ,
1288	date_hw_install          nvarchar2(64)   DEFAULT ''                ,
1289	date_hw_expiry           nvarchar2(64)   DEFAULT ''                ,
1290	date_hw_decomm           nvarchar2(64)   DEFAULT ''                ,
1291	site_address_a           nvarchar2(128)  DEFAULT ''                ,
1292	site_address_b           nvarchar2(128)  DEFAULT ''                ,
1293	site_address_c           nvarchar2(128)  DEFAULT ''                ,
1294	site_city                nvarchar2(128)  DEFAULT ''                ,
1295	site_state               nvarchar2(64)   DEFAULT ''                ,
1296	site_country             nvarchar2(64)   DEFAULT ''                ,
1297	site_zip                 nvarchar2(64)   DEFAULT ''                ,
1298	site_rack                nvarchar2(128)  DEFAULT ''                ,
1299	site_notes               nvarchar2(2048) DEFAULT ''                ,
1300	poc_1_name               nvarchar2(128)  DEFAULT ''                ,
1301	poc_1_email              nvarchar2(128)  DEFAULT ''                ,
1302	poc_1_phone_a            nvarchar2(64)   DEFAULT ''                ,
1303	poc_1_phone_b            nvarchar2(64)   DEFAULT ''                ,
1304	poc_1_cell               nvarchar2(64)   DEFAULT ''                ,
1305	poc_1_screen             nvarchar2(64)   DEFAULT ''                ,
1306	poc_1_notes              nvarchar2(2048) DEFAULT ''                ,
1307	poc_2_name               nvarchar2(128)  DEFAULT ''                ,
1308	poc_2_email              nvarchar2(128)  DEFAULT ''                ,
1309	poc_2_phone_a            nvarchar2(64)   DEFAULT ''                ,
1310	poc_2_phone_b            nvarchar2(64)   DEFAULT ''                ,
1311	poc_2_cell               nvarchar2(64)   DEFAULT ''                ,
1312	poc_2_screen             nvarchar2(64)   DEFAULT ''                ,
1313	poc_2_notes              nvarchar2(2048) DEFAULT ''                ,
1314	PRIMARY KEY (hostid)
1315);
1316CREATE TABLE housekeeper (
1317	housekeeperid            number(20)                                NOT NULL,
1318	tablename                nvarchar2(64)   DEFAULT ''                ,
1319	field                    nvarchar2(64)   DEFAULT ''                ,
1320	value                    number(20)                                NOT NULL,
1321	PRIMARY KEY (housekeeperid)
1322);
1323CREATE TABLE images (
1324	imageid                  number(20)                                NOT NULL,
1325	imagetype                number(10)      DEFAULT '0'               NOT NULL,
1326	name                     nvarchar2(64)   DEFAULT '0'               ,
1327	image                    blob            DEFAULT ''                NOT NULL,
1328	PRIMARY KEY (imageid)
1329);
1330CREATE UNIQUE INDEX images_1 ON images (name);
1331CREATE TABLE item_discovery (
1332	itemdiscoveryid          number(20)                                NOT NULL,
1333	itemid                   number(20)                                NOT NULL,
1334	parent_itemid            number(20)                                NOT NULL,
1335	key_                     nvarchar2(255)  DEFAULT ''                ,
1336	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1337	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1338	PRIMARY KEY (itemdiscoveryid)
1339);
1340CREATE UNIQUE INDEX item_discovery_1 ON item_discovery (itemid,parent_itemid);
1341CREATE INDEX item_discovery_2 ON item_discovery (parent_itemid);
1342CREATE TABLE host_discovery (
1343	hostid                   number(20)                                NOT NULL,
1344	parent_hostid            number(20)                                NULL,
1345	parent_itemid            number(20)                                NULL,
1346	host                     nvarchar2(64)   DEFAULT ''                ,
1347	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1348	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1349	PRIMARY KEY (hostid)
1350);
1351CREATE TABLE interface_discovery (
1352	interfaceid              number(20)                                NOT NULL,
1353	parent_interfaceid       number(20)                                NOT NULL,
1354	PRIMARY KEY (interfaceid)
1355);
1356CREATE TABLE profiles (
1357	profileid                number(20)                                NOT NULL,
1358	userid                   number(20)                                NOT NULL,
1359	idx                      nvarchar2(96)   DEFAULT ''                ,
1360	idx2                     number(20)      DEFAULT '0'               NOT NULL,
1361	value_id                 number(20)      DEFAULT '0'               NOT NULL,
1362	value_int                number(10)      DEFAULT '0'               NOT NULL,
1363	value_str                nvarchar2(255)  DEFAULT ''                ,
1364	source                   nvarchar2(96)   DEFAULT ''                ,
1365	type                     number(10)      DEFAULT '0'               NOT NULL,
1366	PRIMARY KEY (profileid)
1367);
1368CREATE INDEX profiles_1 ON profiles (userid,idx,idx2);
1369CREATE INDEX profiles_2 ON profiles (userid,profileid);
1370CREATE TABLE sessions (
1371	sessionid                nvarchar2(32)   DEFAULT ''                ,
1372	userid                   number(20)                                NOT NULL,
1373	lastaccess               number(10)      DEFAULT '0'               NOT NULL,
1374	status                   number(10)      DEFAULT '0'               NOT NULL,
1375	PRIMARY KEY (sessionid)
1376);
1377CREATE INDEX sessions_1 ON sessions (userid,status);
1378CREATE TABLE trigger_discovery (
1379	triggerid                number(20)                                NOT NULL,
1380	parent_triggerid         number(20)                                NOT NULL,
1381	PRIMARY KEY (triggerid)
1382);
1383CREATE INDEX trigger_discovery_1 ON trigger_discovery (parent_triggerid);
1384CREATE TABLE application_template (
1385	application_templateid   number(20)                                NOT NULL,
1386	applicationid            number(20)                                NOT NULL,
1387	templateid               number(20)                                NOT NULL,
1388	PRIMARY KEY (application_templateid)
1389);
1390CREATE UNIQUE INDEX application_template_1 ON application_template (applicationid,templateid);
1391CREATE INDEX application_template_2 ON application_template (templateid);
1392CREATE TABLE item_condition (
1393	item_conditionid         number(20)                                NOT NULL,
1394	itemid                   number(20)                                NOT NULL,
1395	operator                 number(10)      DEFAULT '8'               NOT NULL,
1396	macro                    nvarchar2(64)   DEFAULT ''                ,
1397	value                    nvarchar2(255)  DEFAULT ''                ,
1398	PRIMARY KEY (item_conditionid)
1399);
1400CREATE INDEX item_condition_1 ON item_condition (itemid);
1401CREATE TABLE application_prototype (
1402	application_prototypeid  number(20)                                NOT NULL,
1403	itemid                   number(20)                                NOT NULL,
1404	templateid               number(20)                                NULL,
1405	name                     nvarchar2(255)  DEFAULT ''                ,
1406	PRIMARY KEY (application_prototypeid)
1407);
1408CREATE INDEX application_prototype_1 ON application_prototype (itemid);
1409CREATE INDEX application_prototype_2 ON application_prototype (templateid);
1410CREATE TABLE item_application_prototype (
1411	item_application_prototypeid number(20)                                NOT NULL,
1412	application_prototypeid  number(20)                                NOT NULL,
1413	itemid                   number(20)                                NOT NULL,
1414	PRIMARY KEY (item_application_prototypeid)
1415);
1416CREATE UNIQUE INDEX item_application_prototype_1 ON item_application_prototype (application_prototypeid,itemid);
1417CREATE INDEX item_application_prototype_2 ON item_application_prototype (itemid);
1418CREATE TABLE application_discovery (
1419	application_discoveryid  number(20)                                NOT NULL,
1420	applicationid            number(20)                                NOT NULL,
1421	application_prototypeid  number(20)                                NOT NULL,
1422	name                     nvarchar2(255)  DEFAULT ''                ,
1423	lastcheck                number(10)      DEFAULT '0'               NOT NULL,
1424	ts_delete                number(10)      DEFAULT '0'               NOT NULL,
1425	PRIMARY KEY (application_discoveryid)
1426);
1427CREATE INDEX application_discovery_1 ON application_discovery (applicationid);
1428CREATE INDEX application_discovery_2 ON application_discovery (application_prototypeid);
1429CREATE TABLE opinventory (
1430	operationid              number(20)                                NOT NULL,
1431	inventory_mode           number(10)      DEFAULT '0'               NOT NULL,
1432	PRIMARY KEY (operationid)
1433);
1434CREATE TABLE dbversion (
1435	mandatory                number(10)      DEFAULT '0'               NOT NULL,
1436	optional                 number(10)      DEFAULT '0'               NOT NULL
1437);
1438INSERT INTO dbversion VALUES ('3000000','3000000');
1439CREATE SEQUENCE proxy_history_seq
1440START WITH 1
1441INCREMENT BY 1
1442NOMAXVALUE
1443/
1444CREATE TRIGGER proxy_history_tr
1445BEFORE INSERT ON proxy_history
1446FOR EACH ROW
1447BEGIN
1448SELECT proxy_history_seq.nextval INTO :new.id FROM dual;
1449END;
1450/
1451CREATE SEQUENCE proxy_dhistory_seq
1452START WITH 1
1453INCREMENT BY 1
1454NOMAXVALUE
1455/
1456CREATE TRIGGER proxy_dhistory_tr
1457BEFORE INSERT ON proxy_dhistory
1458FOR EACH ROW
1459BEGIN
1460SELECT proxy_dhistory_seq.nextval INTO :new.id FROM dual;
1461END;
1462/
1463CREATE SEQUENCE proxy_autoreg_host_seq
1464START WITH 1
1465INCREMENT BY 1
1466NOMAXVALUE
1467/
1468CREATE TRIGGER proxy_autoreg_host_tr
1469BEFORE INSERT ON proxy_autoreg_host
1470FOR EACH ROW
1471BEGIN
1472SELECT proxy_autoreg_host_seq.nextval INTO :new.id FROM dual;
1473END;
1474/
1475ALTER TABLE hosts ADD CONSTRAINT c_hosts_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid);
1476ALTER TABLE hosts ADD CONSTRAINT c_hosts_2 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid);
1477ALTER TABLE hosts ADD CONSTRAINT c_hosts_3 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1478ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1479ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_2 FOREIGN KEY (groupid) REFERENCES groups (groupid);
1480ALTER TABLE group_prototype ADD CONSTRAINT c_group_prototype_3 FOREIGN KEY (templateid) REFERENCES group_prototype (group_prototypeid) ON DELETE CASCADE;
1481ALTER TABLE group_discovery ADD CONSTRAINT c_group_discovery_1 FOREIGN KEY (groupid) REFERENCES groups (groupid) ON DELETE CASCADE;
1482ALTER TABLE group_discovery ADD CONSTRAINT c_group_discovery_2 FOREIGN KEY (parent_group_prototypeid) REFERENCES group_prototype (group_prototypeid);
1483ALTER TABLE screens ADD CONSTRAINT c_screens_1 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1484ALTER TABLE screens ADD CONSTRAINT c_screens_3 FOREIGN KEY (userid) REFERENCES users (userid);
1485ALTER TABLE screens_items ADD CONSTRAINT c_screens_items_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1486ALTER TABLE screen_user ADD CONSTRAINT c_screen_user_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1487ALTER TABLE screen_user ADD CONSTRAINT c_screen_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1488ALTER TABLE screen_usrgrp ADD CONSTRAINT c_screen_usrgrp_1 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1489ALTER TABLE screen_usrgrp ADD CONSTRAINT c_screen_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1490ALTER TABLE slideshows ADD CONSTRAINT c_slideshows_3 FOREIGN KEY (userid) REFERENCES users (userid);
1491ALTER TABLE slideshow_user ADD CONSTRAINT c_slideshow_user_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1492ALTER TABLE slideshow_user ADD CONSTRAINT c_slideshow_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1493ALTER TABLE slideshow_usrgrp ADD CONSTRAINT c_slideshow_usrgrp_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1494ALTER TABLE slideshow_usrgrp ADD CONSTRAINT c_slideshow_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1495ALTER TABLE slides ADD CONSTRAINT c_slides_1 FOREIGN KEY (slideshowid) REFERENCES slideshows (slideshowid) ON DELETE CASCADE;
1496ALTER TABLE slides ADD CONSTRAINT c_slides_2 FOREIGN KEY (screenid) REFERENCES screens (screenid) ON DELETE CASCADE;
1497ALTER TABLE drules ADD CONSTRAINT c_drules_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid);
1498ALTER TABLE dchecks ADD CONSTRAINT c_dchecks_1 FOREIGN KEY (druleid) REFERENCES drules (druleid) ON DELETE CASCADE;
1499ALTER TABLE applications ADD CONSTRAINT c_applications_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1500ALTER TABLE httptest ADD CONSTRAINT c_httptest_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid);
1501ALTER TABLE httptest ADD CONSTRAINT c_httptest_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1502ALTER TABLE httptest ADD CONSTRAINT c_httptest_3 FOREIGN KEY (templateid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1503ALTER TABLE httpstep ADD CONSTRAINT c_httpstep_1 FOREIGN KEY (httptestid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1504ALTER TABLE interface ADD CONSTRAINT c_interface_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1505ALTER TABLE items ADD CONSTRAINT c_items_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1506ALTER TABLE items ADD CONSTRAINT c_items_2 FOREIGN KEY (templateid) REFERENCES items (itemid) ON DELETE CASCADE;
1507ALTER TABLE items ADD CONSTRAINT c_items_3 FOREIGN KEY (valuemapid) REFERENCES valuemaps (valuemapid);
1508ALTER TABLE items ADD CONSTRAINT c_items_4 FOREIGN KEY (interfaceid) REFERENCES interface (interfaceid);
1509ALTER TABLE httpstepitem ADD CONSTRAINT c_httpstepitem_1 FOREIGN KEY (httpstepid) REFERENCES httpstep (httpstepid) ON DELETE CASCADE;
1510ALTER TABLE httpstepitem ADD CONSTRAINT c_httpstepitem_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1511ALTER TABLE httptestitem ADD CONSTRAINT c_httptestitem_1 FOREIGN KEY (httptestid) REFERENCES httptest (httptestid) ON DELETE CASCADE;
1512ALTER TABLE httptestitem ADD CONSTRAINT c_httptestitem_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1513ALTER TABLE users_groups ADD CONSTRAINT c_users_groups_1 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1514ALTER TABLE users_groups ADD CONSTRAINT c_users_groups_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1515ALTER TABLE scripts ADD CONSTRAINT c_scripts_1 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid);
1516ALTER TABLE scripts ADD CONSTRAINT c_scripts_2 FOREIGN KEY (groupid) REFERENCES groups (groupid);
1517ALTER TABLE operations ADD CONSTRAINT c_operations_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1518ALTER TABLE opmessage ADD CONSTRAINT c_opmessage_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1519ALTER TABLE opmessage ADD CONSTRAINT c_opmessage_2 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid);
1520ALTER TABLE opmessage_grp ADD CONSTRAINT c_opmessage_grp_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1521ALTER TABLE opmessage_grp ADD CONSTRAINT c_opmessage_grp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid);
1522ALTER TABLE opmessage_usr ADD CONSTRAINT c_opmessage_usr_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1523ALTER TABLE opmessage_usr ADD CONSTRAINT c_opmessage_usr_2 FOREIGN KEY (userid) REFERENCES users (userid);
1524ALTER TABLE opcommand ADD CONSTRAINT c_opcommand_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1525ALTER TABLE opcommand ADD CONSTRAINT c_opcommand_2 FOREIGN KEY (scriptid) REFERENCES scripts (scriptid);
1526ALTER TABLE opcommand_hst ADD CONSTRAINT c_opcommand_hst_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1527ALTER TABLE opcommand_hst ADD CONSTRAINT c_opcommand_hst_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid);
1528ALTER TABLE opcommand_grp ADD CONSTRAINT c_opcommand_grp_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1529ALTER TABLE opcommand_grp ADD CONSTRAINT c_opcommand_grp_2 FOREIGN KEY (groupid) REFERENCES groups (groupid);
1530ALTER TABLE opgroup ADD CONSTRAINT c_opgroup_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1531ALTER TABLE opgroup ADD CONSTRAINT c_opgroup_2 FOREIGN KEY (groupid) REFERENCES groups (groupid);
1532ALTER TABLE optemplate ADD CONSTRAINT c_optemplate_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1533ALTER TABLE optemplate ADD CONSTRAINT c_optemplate_2 FOREIGN KEY (templateid) REFERENCES hosts (hostid);
1534ALTER TABLE opconditions ADD CONSTRAINT c_opconditions_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1535ALTER TABLE conditions ADD CONSTRAINT c_conditions_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1536ALTER TABLE config ADD CONSTRAINT c_config_1 FOREIGN KEY (alert_usrgrpid) REFERENCES usrgrp (usrgrpid);
1537ALTER TABLE config ADD CONSTRAINT c_config_2 FOREIGN KEY (discovery_groupid) REFERENCES groups (groupid);
1538ALTER TABLE triggers ADD CONSTRAINT c_triggers_1 FOREIGN KEY (templateid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1539ALTER TABLE trigger_depends ADD CONSTRAINT c_trigger_depends_1 FOREIGN KEY (triggerid_down) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1540ALTER TABLE trigger_depends ADD CONSTRAINT c_trigger_depends_2 FOREIGN KEY (triggerid_up) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1541ALTER TABLE functions ADD CONSTRAINT c_functions_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1542ALTER TABLE functions ADD CONSTRAINT c_functions_2 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1543ALTER TABLE graphs ADD CONSTRAINT c_graphs_1 FOREIGN KEY (templateid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1544ALTER TABLE graphs ADD CONSTRAINT c_graphs_2 FOREIGN KEY (ymin_itemid) REFERENCES items (itemid);
1545ALTER TABLE graphs ADD CONSTRAINT c_graphs_3 FOREIGN KEY (ymax_itemid) REFERENCES items (itemid);
1546ALTER TABLE graphs_items ADD CONSTRAINT c_graphs_items_1 FOREIGN KEY (graphid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1547ALTER TABLE graphs_items ADD CONSTRAINT c_graphs_items_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1548ALTER TABLE hostmacro ADD CONSTRAINT c_hostmacro_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1549ALTER TABLE hosts_groups ADD CONSTRAINT c_hosts_groups_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1550ALTER TABLE hosts_groups ADD CONSTRAINT c_hosts_groups_2 FOREIGN KEY (groupid) REFERENCES groups (groupid) ON DELETE CASCADE;
1551ALTER TABLE hosts_templates ADD CONSTRAINT c_hosts_templates_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1552ALTER TABLE hosts_templates ADD CONSTRAINT c_hosts_templates_2 FOREIGN KEY (templateid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1553ALTER TABLE items_applications ADD CONSTRAINT c_items_applications_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1554ALTER TABLE items_applications ADD CONSTRAINT c_items_applications_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1555ALTER TABLE mappings ADD CONSTRAINT c_mappings_1 FOREIGN KEY (valuemapid) REFERENCES valuemaps (valuemapid) ON DELETE CASCADE;
1556ALTER TABLE media ADD CONSTRAINT c_media_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1557ALTER TABLE media ADD CONSTRAINT c_media_2 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid) ON DELETE CASCADE;
1558ALTER TABLE rights ADD CONSTRAINT c_rights_1 FOREIGN KEY (groupid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1559ALTER TABLE rights ADD CONSTRAINT c_rights_2 FOREIGN KEY (id) REFERENCES groups (groupid) ON DELETE CASCADE;
1560ALTER TABLE services ADD CONSTRAINT c_services_1 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1561ALTER TABLE services_links ADD CONSTRAINT c_services_links_1 FOREIGN KEY (serviceupid) REFERENCES services (serviceid) ON DELETE CASCADE;
1562ALTER TABLE services_links ADD CONSTRAINT c_services_links_2 FOREIGN KEY (servicedownid) REFERENCES services (serviceid) ON DELETE CASCADE;
1563ALTER TABLE services_times ADD CONSTRAINT c_services_times_1 FOREIGN KEY (serviceid) REFERENCES services (serviceid) ON DELETE CASCADE;
1564ALTER TABLE icon_map ADD CONSTRAINT c_icon_map_1 FOREIGN KEY (default_iconid) REFERENCES images (imageid);
1565ALTER TABLE icon_mapping ADD CONSTRAINT c_icon_mapping_1 FOREIGN KEY (iconmapid) REFERENCES icon_map (iconmapid) ON DELETE CASCADE;
1566ALTER TABLE icon_mapping ADD CONSTRAINT c_icon_mapping_2 FOREIGN KEY (iconid) REFERENCES images (imageid);
1567ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_1 FOREIGN KEY (backgroundid) REFERENCES images (imageid);
1568ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_2 FOREIGN KEY (iconmapid) REFERENCES icon_map (iconmapid);
1569ALTER TABLE sysmaps ADD CONSTRAINT c_sysmaps_3 FOREIGN KEY (userid) REFERENCES users (userid);
1570ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1571ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_2 FOREIGN KEY (iconid_off) REFERENCES images (imageid);
1572ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_3 FOREIGN KEY (iconid_on) REFERENCES images (imageid);
1573ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_4 FOREIGN KEY (iconid_disabled) REFERENCES images (imageid);
1574ALTER TABLE sysmaps_elements ADD CONSTRAINT c_sysmaps_elements_5 FOREIGN KEY (iconid_maintenance) REFERENCES images (imageid);
1575ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1576ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_2 FOREIGN KEY (selementid1) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1577ALTER TABLE sysmaps_links ADD CONSTRAINT c_sysmaps_links_3 FOREIGN KEY (selementid2) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1578ALTER TABLE sysmaps_link_triggers ADD CONSTRAINT c_sysmaps_link_triggers_1 FOREIGN KEY (linkid) REFERENCES sysmaps_links (linkid) ON DELETE CASCADE;
1579ALTER TABLE sysmaps_link_triggers ADD CONSTRAINT c_sysmaps_link_triggers_2 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1580ALTER TABLE sysmap_element_url ADD CONSTRAINT c_sysmap_element_url_1 FOREIGN KEY (selementid) REFERENCES sysmaps_elements (selementid) ON DELETE CASCADE;
1581ALTER TABLE sysmap_url ADD CONSTRAINT c_sysmap_url_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1582ALTER TABLE sysmap_user ADD CONSTRAINT c_sysmap_user_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1583ALTER TABLE sysmap_user ADD CONSTRAINT c_sysmap_user_2 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1584ALTER TABLE sysmap_usrgrp ADD CONSTRAINT c_sysmap_usrgrp_1 FOREIGN KEY (sysmapid) REFERENCES sysmaps (sysmapid) ON DELETE CASCADE;
1585ALTER TABLE sysmap_usrgrp ADD CONSTRAINT c_sysmap_usrgrp_2 FOREIGN KEY (usrgrpid) REFERENCES usrgrp (usrgrpid) ON DELETE CASCADE;
1586ALTER TABLE maintenances_hosts ADD CONSTRAINT c_maintenances_hosts_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1587ALTER TABLE maintenances_hosts ADD CONSTRAINT c_maintenances_hosts_2 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1588ALTER TABLE maintenances_groups ADD CONSTRAINT c_maintenances_groups_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1589ALTER TABLE maintenances_groups ADD CONSTRAINT c_maintenances_groups_2 FOREIGN KEY (groupid) REFERENCES groups (groupid) ON DELETE CASCADE;
1590ALTER TABLE maintenances_windows ADD CONSTRAINT c_maintenances_windows_1 FOREIGN KEY (maintenanceid) REFERENCES maintenances (maintenanceid) ON DELETE CASCADE;
1591ALTER TABLE maintenances_windows ADD CONSTRAINT c_maintenances_windows_2 FOREIGN KEY (timeperiodid) REFERENCES timeperiods (timeperiodid) ON DELETE CASCADE;
1592ALTER TABLE expressions ADD CONSTRAINT c_expressions_1 FOREIGN KEY (regexpid) REFERENCES regexps (regexpid) ON DELETE CASCADE;
1593ALTER TABLE alerts ADD CONSTRAINT c_alerts_1 FOREIGN KEY (actionid) REFERENCES actions (actionid) ON DELETE CASCADE;
1594ALTER TABLE alerts ADD CONSTRAINT c_alerts_2 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1595ALTER TABLE alerts ADD CONSTRAINT c_alerts_3 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1596ALTER TABLE alerts ADD CONSTRAINT c_alerts_4 FOREIGN KEY (mediatypeid) REFERENCES media_type (mediatypeid) ON DELETE CASCADE;
1597ALTER TABLE acknowledges ADD CONSTRAINT c_acknowledges_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1598ALTER TABLE acknowledges ADD CONSTRAINT c_acknowledges_2 FOREIGN KEY (eventid) REFERENCES events (eventid) ON DELETE CASCADE;
1599ALTER TABLE auditlog ADD CONSTRAINT c_auditlog_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1600ALTER TABLE auditlog_details ADD CONSTRAINT c_auditlog_details_1 FOREIGN KEY (auditid) REFERENCES auditlog (auditid) ON DELETE CASCADE;
1601ALTER TABLE service_alarms ADD CONSTRAINT c_service_alarms_1 FOREIGN KEY (serviceid) REFERENCES services (serviceid) ON DELETE CASCADE;
1602ALTER TABLE autoreg_host ADD CONSTRAINT c_autoreg_host_1 FOREIGN KEY (proxy_hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1603ALTER TABLE dhosts ADD CONSTRAINT c_dhosts_1 FOREIGN KEY (druleid) REFERENCES drules (druleid) ON DELETE CASCADE;
1604ALTER TABLE dservices ADD CONSTRAINT c_dservices_1 FOREIGN KEY (dhostid) REFERENCES dhosts (dhostid) ON DELETE CASCADE;
1605ALTER TABLE dservices ADD CONSTRAINT c_dservices_2 FOREIGN KEY (dcheckid) REFERENCES dchecks (dcheckid) ON DELETE CASCADE;
1606ALTER TABLE graph_discovery ADD CONSTRAINT c_graph_discovery_1 FOREIGN KEY (graphid) REFERENCES graphs (graphid) ON DELETE CASCADE;
1607ALTER TABLE graph_discovery ADD CONSTRAINT c_graph_discovery_2 FOREIGN KEY (parent_graphid) REFERENCES graphs (graphid);
1608ALTER TABLE host_inventory ADD CONSTRAINT c_host_inventory_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1609ALTER TABLE item_discovery ADD CONSTRAINT c_item_discovery_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1610ALTER TABLE item_discovery ADD CONSTRAINT c_item_discovery_2 FOREIGN KEY (parent_itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1611ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_1 FOREIGN KEY (hostid) REFERENCES hosts (hostid) ON DELETE CASCADE;
1612ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_2 FOREIGN KEY (parent_hostid) REFERENCES hosts (hostid);
1613ALTER TABLE host_discovery ADD CONSTRAINT c_host_discovery_3 FOREIGN KEY (parent_itemid) REFERENCES items (itemid);
1614ALTER TABLE interface_discovery ADD CONSTRAINT c_interface_discovery_1 FOREIGN KEY (interfaceid) REFERENCES interface (interfaceid) ON DELETE CASCADE;
1615ALTER TABLE interface_discovery ADD CONSTRAINT c_interface_discovery_2 FOREIGN KEY (parent_interfaceid) REFERENCES interface (interfaceid) ON DELETE CASCADE;
1616ALTER TABLE profiles ADD CONSTRAINT c_profiles_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1617ALTER TABLE sessions ADD CONSTRAINT c_sessions_1 FOREIGN KEY (userid) REFERENCES users (userid) ON DELETE CASCADE;
1618ALTER TABLE trigger_discovery ADD CONSTRAINT c_trigger_discovery_1 FOREIGN KEY (triggerid) REFERENCES triggers (triggerid) ON DELETE CASCADE;
1619ALTER TABLE trigger_discovery ADD CONSTRAINT c_trigger_discovery_2 FOREIGN KEY (parent_triggerid) REFERENCES triggers (triggerid);
1620ALTER TABLE application_template ADD CONSTRAINT c_application_template_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1621ALTER TABLE application_template ADD CONSTRAINT c_application_template_2 FOREIGN KEY (templateid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1622ALTER TABLE item_condition ADD CONSTRAINT c_item_condition_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1623ALTER TABLE application_prototype ADD CONSTRAINT c_application_prototype_1 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1624ALTER TABLE application_prototype ADD CONSTRAINT c_application_prototype_2 FOREIGN KEY (templateid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1625ALTER TABLE item_application_prototype ADD CONSTRAINT c_item_application_prototype_1 FOREIGN KEY (application_prototypeid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1626ALTER TABLE item_application_prototype ADD CONSTRAINT c_item_application_prototype_2 FOREIGN KEY (itemid) REFERENCES items (itemid) ON DELETE CASCADE;
1627ALTER TABLE application_discovery ADD CONSTRAINT c_application_discovery_1 FOREIGN KEY (applicationid) REFERENCES applications (applicationid) ON DELETE CASCADE;
1628ALTER TABLE application_discovery ADD CONSTRAINT c_application_discovery_2 FOREIGN KEY (application_prototypeid) REFERENCES application_prototype (application_prototypeid) ON DELETE CASCADE;
1629ALTER TABLE opinventory ADD CONSTRAINT c_opinventory_1 FOREIGN KEY (operationid) REFERENCES operations (operationid) ON DELETE CASCADE;
1630