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