]> granicus.if.org Git - icinga2/blob - lib/db_ido_mysql/schema/mysql.sql
Fix version number if schema/{mysql,pgsql}.sql
[icinga2] / lib / db_ido_mysql / schema / mysql.sql
1 -- --------------------------------------------------------
2 -- mysql.sql
3 -- DB definition for MySQL
4 --
5 -- Copyright (c) 2009-2014 Icinga Development Team (http://www.icinga.org)
6 --
7 -- -- --------------------------------------------------------
8
9 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
10
11
12 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
13 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
14 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
15 /*!40101 SET NAMES utf8 */;
16
17
18 --
19 -- Database: icinga
20 --
21
22 -- --------------------------------------------------------
23
24 --
25 -- Table structure for table icinga_acknowledgements
26 --
27
28 CREATE TABLE IF NOT EXISTS icinga_acknowledgements (
29   acknowledgement_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
30   instance_id bigint unsigned default 0,
31   entry_time timestamp  default '0000-00-00 00:00:00',
32   entry_time_usec  int default 0,
33   acknowledgement_type smallint default 0,
34   object_id bigint unsigned default 0,
35   state smallint default 0,
36   author_name varchar(64) character set latin1  default '',
37   comment_data TEXT character set latin1  default '',
38   is_sticky smallint default 0,
39   persistent_comment smallint default 0,
40   notify_contacts smallint default 0,
41   end_time timestamp default '0000-00-00 00:00:00',
42   PRIMARY KEY  (acknowledgement_id)
43 ) ENGINE=InnoDB COMMENT='Current and historical host and service acknowledgements';
44
45 -- --------------------------------------------------------
46
47 --
48 -- Table structure for table icinga_commands
49 --
50
51 CREATE TABLE IF NOT EXISTS icinga_commands (
52   command_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
53   instance_id bigint unsigned default 0,
54   config_type smallint default 0,
55   object_id bigint unsigned default 0,
56   command_line TEXT character set latin1  default '',
57   PRIMARY KEY  (command_id),
58   UNIQUE KEY instance_id (instance_id,object_id,config_type)
59 ) ENGINE=InnoDB  COMMENT='Command definitions';
60
61 -- --------------------------------------------------------
62
63 --
64 -- Table structure for table icinga_commenthistory
65 --
66
67 CREATE TABLE IF NOT EXISTS icinga_commenthistory (
68   commenthistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
69   instance_id bigint unsigned default 0,
70   entry_time timestamp  default '0000-00-00 00:00:00',
71   entry_time_usec  int default 0,
72   comment_type smallint default 0,
73   entry_type smallint default 0,
74   object_id bigint unsigned default 0,
75   comment_time timestamp  default '0000-00-00 00:00:00',
76   internal_comment_id bigint unsigned default 0,
77   author_name varchar(64) character set latin1  default '',
78   comment_data TEXT character set latin1  default '',
79   is_persistent smallint default 0,
80   comment_source smallint default 0,
81   expires smallint default 0,
82   expiration_time timestamp  default '0000-00-00 00:00:00',
83   deletion_time timestamp  default '0000-00-00 00:00:00',
84   deletion_time_usec  int default 0,
85   PRIMARY KEY  (commenthistory_id),
86   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
87 ) ENGINE=InnoDB  COMMENT='Historical host and service comments';
88
89 -- --------------------------------------------------------
90
91 --
92 -- Table structure for table icinga_comments
93 --
94
95 CREATE TABLE IF NOT EXISTS icinga_comments (
96   comment_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
97   instance_id bigint unsigned default 0,
98   entry_time timestamp  default '0000-00-00 00:00:00',
99   entry_time_usec  int default 0,
100   comment_type smallint default 0,
101   entry_type smallint default 0,
102   object_id bigint unsigned default 0,
103   comment_time timestamp  default '0000-00-00 00:00:00',
104   internal_comment_id bigint unsigned default 0,
105   author_name varchar(64) character set latin1  default '',
106   comment_data TEXT character set latin1  default '',
107   is_persistent smallint default 0,
108   comment_source smallint default 0,
109   expires smallint default 0,
110   expiration_time timestamp  default '0000-00-00 00:00:00',
111   PRIMARY KEY  (comment_id),
112   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
113 ) ENGINE=InnoDB  COMMENT='Usercomments on Icinga objects';
114
115 -- --------------------------------------------------------
116
117 --
118 -- Table structure for table icinga_configfiles
119 --
120
121 CREATE TABLE IF NOT EXISTS icinga_configfiles (
122   configfile_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
123   instance_id bigint unsigned default 0,
124   configfile_type smallint default 0,
125   configfile_path varchar(255) character set latin1  default '',
126   PRIMARY KEY  (configfile_id),
127   UNIQUE KEY instance_id (instance_id,configfile_type,configfile_path)
128 ) ENGINE=InnoDB  COMMENT='Configuration files';
129
130 -- --------------------------------------------------------
131
132 --
133 -- Table structure for table icinga_configfilevariables
134 --
135
136 CREATE TABLE IF NOT EXISTS icinga_configfilevariables (
137   configfilevariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
138   instance_id bigint unsigned default 0,
139   configfile_id bigint unsigned default 0,
140   varname varchar(64) character set latin1  default '',
141   varvalue TEXT character set latin1  default '',
142   PRIMARY KEY  (configfilevariable_id)
143 ) ENGINE=InnoDB  COMMENT='Configuration file variables';
144
145 -- --------------------------------------------------------
146
147 --
148 -- Table structure for table icinga_conninfo
149 --
150
151 CREATE TABLE IF NOT EXISTS icinga_conninfo (
152   conninfo_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
153   instance_id bigint unsigned default 0,
154   agent_name varchar(32) character set latin1  default '',
155   agent_version varchar(32) character set latin1  default '',
156   disposition varchar(32) character set latin1  default '',
157   connect_source varchar(32) character set latin1  default '',
158   connect_type varchar(32) character set latin1  default '',
159   connect_time timestamp  default '0000-00-00 00:00:00',
160   disconnect_time timestamp  default '0000-00-00 00:00:00',
161   last_checkin_time timestamp  default '0000-00-00 00:00:00',
162   data_start_time timestamp  default '0000-00-00 00:00:00',
163   data_end_time timestamp  default '0000-00-00 00:00:00',
164   bytes_processed bigint unsigned  default '0',
165   lines_processed bigint unsigned  default '0',
166   entries_processed bigint unsigned  default '0',
167   PRIMARY KEY  (conninfo_id)
168 ) ENGINE=InnoDB  COMMENT='IDO2DB daemon connection information';
169
170 -- --------------------------------------------------------
171
172 --
173 -- Table structure for table icinga_contactgroups
174 --
175
176 CREATE TABLE IF NOT EXISTS icinga_contactgroups (
177   contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
178   instance_id bigint unsigned default 0,
179   config_type smallint default 0,
180   contactgroup_object_id bigint unsigned default 0,
181   alias TEXT character set latin1  default '',
182   PRIMARY KEY  (contactgroup_id),
183   UNIQUE KEY instance_id (instance_id,config_type,contactgroup_object_id)
184 ) ENGINE=InnoDB  COMMENT='Contactgroup definitions';
185
186 -- --------------------------------------------------------
187
188 --
189 -- Table structure for table icinga_contactgroup_members
190 --
191
192 CREATE TABLE IF NOT EXISTS icinga_contactgroup_members (
193   contactgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
194   instance_id bigint unsigned default 0,
195   contactgroup_id bigint unsigned default 0,
196   contact_object_id bigint unsigned default 0,
197   PRIMARY KEY  (contactgroup_member_id)
198 ) ENGINE=InnoDB  COMMENT='Contactgroup members';
199
200 -- --------------------------------------------------------
201
202 --
203 -- Table structure for table icinga_contactnotificationmethods
204 --
205
206 CREATE TABLE IF NOT EXISTS icinga_contactnotificationmethods (
207   contactnotificationmethod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
208   instance_id bigint unsigned default 0,
209   contactnotification_id bigint unsigned default 0,
210   start_time timestamp  default '0000-00-00 00:00:00',
211   start_time_usec  int default 0,
212   end_time timestamp  default '0000-00-00 00:00:00',
213   end_time_usec  int default 0,
214   command_object_id bigint unsigned default 0,
215   command_args TEXT character set latin1  default '',
216   PRIMARY KEY  (contactnotificationmethod_id),
217   UNIQUE KEY instance_id (instance_id,contactnotification_id,start_time,start_time_usec)
218 ) ENGINE=InnoDB  COMMENT='Historical record of contact notification methods';
219
220 -- --------------------------------------------------------
221
222 --
223 -- Table structure for table icinga_contactnotifications
224 --
225
226 CREATE TABLE IF NOT EXISTS icinga_contactnotifications (
227   contactnotification_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
228   instance_id bigint unsigned default 0,
229   notification_id bigint unsigned default 0,
230   contact_object_id bigint unsigned default 0,
231   start_time timestamp  default '0000-00-00 00:00:00',
232   start_time_usec  int default 0,
233   end_time timestamp  default '0000-00-00 00:00:00',
234   end_time_usec  int default 0,
235   PRIMARY KEY  (contactnotification_id),
236   UNIQUE KEY instance_id (instance_id,contact_object_id,start_time,start_time_usec)
237 ) ENGINE=InnoDB  COMMENT='Historical record of contact notifications';
238
239 -- --------------------------------------------------------
240
241 --
242 -- Table structure for table icinga_contacts
243 --
244
245 CREATE TABLE IF NOT EXISTS icinga_contacts (
246   contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
247   instance_id bigint unsigned default 0,
248   config_type smallint default 0,
249   contact_object_id bigint unsigned default 0,
250   alias varchar(64) character set latin1  default '',
251   email_address varchar(255) character set latin1  default '',
252   pager_address varchar(64) character set latin1  default '',
253   host_timeperiod_object_id bigint unsigned default 0,
254   service_timeperiod_object_id bigint unsigned default 0,
255   host_notifications_enabled smallint default 0,
256   service_notifications_enabled smallint default 0,
257   can_submit_commands smallint default 0,
258   notify_service_recovery smallint default 0,
259   notify_service_warning smallint default 0,
260   notify_service_unknown smallint default 0,
261   notify_service_critical smallint default 0,
262   notify_service_flapping smallint default 0,
263   notify_service_downtime smallint default 0,
264   notify_host_recovery smallint default 0,
265   notify_host_down smallint default 0,
266   notify_host_unreachable smallint default 0,
267   notify_host_flapping smallint default 0,
268   notify_host_downtime smallint default 0,
269   PRIMARY KEY  (contact_id),
270   UNIQUE KEY instance_id (instance_id,config_type,contact_object_id)
271 ) ENGINE=InnoDB  COMMENT='Contact definitions';
272
273 -- --------------------------------------------------------
274
275 --
276 -- Table structure for table icinga_contactstatus
277 --
278
279 CREATE TABLE IF NOT EXISTS icinga_contactstatus (
280   contactstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
281   instance_id bigint unsigned default 0,
282   contact_object_id bigint unsigned default 0,
283   status_update_time timestamp  default '0000-00-00 00:00:00',
284   host_notifications_enabled smallint default 0,
285   service_notifications_enabled smallint default 0,
286   last_host_notification timestamp  default '0000-00-00 00:00:00',
287   last_service_notification timestamp  default '0000-00-00 00:00:00',
288   modified_attributes  int default 0,
289   modified_host_attributes  int default 0,
290   modified_service_attributes  int default 0,
291   PRIMARY KEY  (contactstatus_id),
292   UNIQUE KEY contact_object_id (contact_object_id)
293 ) ENGINE=InnoDB  COMMENT='Contact status';
294
295 -- --------------------------------------------------------
296
297 --
298 -- Table structure for table icinga_contact_addresses
299 --
300
301 CREATE TABLE IF NOT EXISTS icinga_contact_addresses (
302   contact_address_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
303   instance_id bigint unsigned default 0,
304   contact_id bigint unsigned default 0,
305   address_number smallint default 0,
306   address varchar(255) character set latin1  default '',
307   PRIMARY KEY  (contact_address_id),
308   UNIQUE KEY contact_id (contact_id,address_number)
309 ) ENGINE=InnoDB COMMENT='Contact addresses';
310
311 -- --------------------------------------------------------
312
313 --
314 -- Table structure for table icinga_contact_notificationcommands
315 --
316
317 CREATE TABLE IF NOT EXISTS icinga_contact_notificationcommands (
318   contact_notificationcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
319   instance_id bigint unsigned default 0,
320   contact_id bigint unsigned default 0,
321   notification_type smallint default 0,
322   command_object_id bigint unsigned default 0,
323   command_args varchar(255) character set latin1  default '',
324   PRIMARY KEY  (contact_notificationcommand_id),
325   UNIQUE KEY contact_id (contact_id,notification_type,command_object_id,command_args)
326 ) ENGINE=InnoDB  COMMENT='Contact host and service notification commands';
327
328 -- --------------------------------------------------------
329
330 --
331 -- Table structure for table icinga_customvariables
332 --
333
334 CREATE TABLE IF NOT EXISTS icinga_customvariables (
335   customvariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
336   instance_id bigint unsigned default 0,
337   object_id bigint unsigned default 0,
338   config_type smallint default 0,
339   has_been_modified smallint default 0,
340   varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
341   varvalue TEXT character set latin1  default '',
342   PRIMARY KEY  (customvariable_id),
343   UNIQUE KEY object_id_2 (object_id,config_type,varname),
344   KEY varname (varname)
345 ) ENGINE=InnoDB COMMENT='Custom variables';
346
347 -- --------------------------------------------------------
348
349 --
350 -- Table structure for table icinga_customvariablestatus
351 --
352
353 CREATE TABLE IF NOT EXISTS icinga_customvariablestatus (
354   customvariablestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
355   instance_id bigint unsigned default 0,
356   object_id bigint unsigned default 0,
357   status_update_time timestamp  default '0000-00-00 00:00:00',
358   has_been_modified smallint default 0,
359   varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
360   varvalue TEXT character set latin1  default '',
361   PRIMARY KEY  (customvariablestatus_id),
362   UNIQUE KEY object_id_2 (object_id,varname),
363   KEY varname (varname)
364 ) ENGINE=InnoDB COMMENT='Custom variable status information';
365
366 -- --------------------------------------------------------
367
368 --
369 -- Table structure for table icinga_dbversion
370 --
371
372 CREATE TABLE IF NOT EXISTS icinga_dbversion (
373   dbversion_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
374   name varchar(10) character set latin1  default '',
375   version varchar(10) character set latin1  default '',
376   create_time timestamp default '0000-00-00 00:00:00',
377   modify_time timestamp default '0000-00-00 00:00:00',
378   PRIMARY KEY (dbversion_id),
379   UNIQUE KEY dbversion (name)
380 ) ENGINE=InnoDB;
381
382 -- --------------------------------------------------------
383
384 --
385 -- Table structure for table icinga_downtimehistory
386 --
387
388 CREATE TABLE IF NOT EXISTS icinga_downtimehistory (
389   downtimehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
390   instance_id bigint unsigned default 0,
391   downtime_type smallint default 0,
392   object_id bigint unsigned default 0,
393   entry_time timestamp  default '0000-00-00 00:00:00',
394   author_name varchar(64) character set latin1  default '',
395   comment_data TEXT character set latin1  default '',
396   internal_downtime_id bigint unsigned default 0,
397   triggered_by_id bigint unsigned default 0,
398   is_fixed smallint default 0,
399   duration bigint(20) default 0,
400   scheduled_start_time timestamp  default '0000-00-00 00:00:00',
401   scheduled_end_time timestamp  default '0000-00-00 00:00:00',
402   was_started smallint default 0,
403   actual_start_time timestamp  default '0000-00-00 00:00:00',
404   actual_start_time_usec  int default 0,
405   actual_end_time timestamp  default '0000-00-00 00:00:00',
406   actual_end_time_usec  int default 0,
407   was_cancelled smallint default 0,
408   is_in_effect smallint default 0,
409   trigger_time timestamp  default '0000-00-00 00:00:00',
410   PRIMARY KEY  (downtimehistory_id),
411   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
412 ) ENGINE=InnoDB  COMMENT='Historical scheduled host and service downtime';
413
414 -- --------------------------------------------------------
415
416 --
417 -- Table structure for table icinga_eventhandlers
418 --
419
420 CREATE TABLE IF NOT EXISTS icinga_eventhandlers (
421   eventhandler_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
422   instance_id bigint unsigned default 0,
423   eventhandler_type smallint default 0,
424   object_id bigint unsigned default 0,
425   state smallint default 0,
426   state_type smallint default 0,
427   start_time timestamp  default '0000-00-00 00:00:00',
428   start_time_usec  int default 0,
429   end_time timestamp  default '0000-00-00 00:00:00',
430   end_time_usec  int default 0,
431   command_object_id bigint unsigned default 0,
432   command_args TEXT character set latin1  default '',
433   command_line TEXT character set latin1  default '',
434   timeout smallint default 0,
435   early_timeout smallint default 0,
436   execution_time double  default '0',
437   return_code smallint default 0,
438   output TEXT character set latin1  default '',
439   long_output TEXT  default '',
440   PRIMARY KEY  (eventhandler_id),
441   UNIQUE KEY instance_id (instance_id,object_id,start_time,start_time_usec)
442 ) ENGINE=InnoDB COMMENT='Historical host and service event handlers';
443
444 -- --------------------------------------------------------
445
446 --
447 -- Table structure for table icinga_externalcommands
448 --
449
450 CREATE TABLE IF NOT EXISTS icinga_externalcommands (
451   externalcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
452   instance_id bigint unsigned default 0,
453   entry_time timestamp  default '0000-00-00 00:00:00',
454   command_type smallint default 0,
455   command_name varchar(128) character set latin1  default '',
456   command_args TEXT character set latin1  default '',
457   PRIMARY KEY  (externalcommand_id)
458 ) ENGINE=InnoDB  COMMENT='Historical record of processed external commands';
459
460 -- --------------------------------------------------------
461
462 --
463 -- Table structure for table icinga_flappinghistory
464 --
465
466 CREATE TABLE IF NOT EXISTS icinga_flappinghistory (
467   flappinghistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
468   instance_id bigint unsigned default 0,
469   event_time timestamp  default '0000-00-00 00:00:00',
470   event_time_usec  int default 0,
471   event_type smallint default 0,
472   reason_type smallint default 0,
473   flapping_type smallint default 0,
474   object_id bigint unsigned default 0,
475   percent_state_change double  default '0',
476   low_threshold double  default '0',
477   high_threshold double  default '0',
478   comment_time timestamp  default '0000-00-00 00:00:00',
479   internal_comment_id bigint unsigned default 0,
480   PRIMARY KEY  (flappinghistory_id)
481 ) ENGINE=InnoDB  COMMENT='Current and historical record of host and service flapping';
482
483 -- --------------------------------------------------------
484
485 --
486 -- Table structure for table icinga_hostchecks
487 --
488
489 CREATE TABLE IF NOT EXISTS icinga_hostchecks (
490   hostcheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
491   instance_id bigint unsigned default 0,
492   host_object_id bigint unsigned default 0,
493   check_type smallint default 0,
494   is_raw_check smallint default 0,
495   current_check_attempt smallint default 0,
496   max_check_attempts smallint default 0,
497   state smallint default 0,
498   state_type smallint default 0,
499   start_time timestamp  default '0000-00-00 00:00:00',
500   start_time_usec  int default 0,
501   end_time timestamp  default '0000-00-00 00:00:00',
502   end_time_usec  int default 0,
503   command_object_id bigint unsigned default 0,
504   command_args TEXT character set latin1  default '',
505   command_line TEXT character set latin1  default '',
506   timeout smallint default 0,
507   early_timeout smallint default 0,
508   execution_time double  default '0',
509   latency double  default '0',
510   return_code smallint default 0,
511   output TEXT character set latin1  default '',
512   long_output TEXT  default '',
513   perfdata TEXT character set latin1  default '',
514   PRIMARY KEY  (hostcheck_id)
515 ) ENGINE=InnoDB  COMMENT='Historical host checks';
516
517 -- --------------------------------------------------------
518
519 --
520 -- Table structure for table icinga_hostdependencies
521 --
522
523 CREATE TABLE IF NOT EXISTS icinga_hostdependencies (
524   hostdependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
525   instance_id bigint unsigned default 0,
526   config_type smallint default 0,
527   host_object_id bigint unsigned default 0,
528   dependent_host_object_id bigint unsigned default 0,
529   dependency_type smallint default 0,
530   inherits_parent smallint default 0,
531   timeperiod_object_id bigint unsigned default 0,
532   fail_on_up smallint default 0,
533   fail_on_down smallint default 0,
534   fail_on_unreachable smallint default 0,
535   PRIMARY KEY  (hostdependency_id),
536   UNIQUE KEY instance_id (instance_id,config_type,host_object_id,dependent_host_object_id,dependency_type,inherits_parent,fail_on_up,fail_on_down,fail_on_unreachable)
537 ) ENGINE=InnoDB COMMENT='Host dependency definitions';
538
539 -- --------------------------------------------------------
540
541 --
542 -- Table structure for table icinga_hostescalations
543 --
544
545 CREATE TABLE IF NOT EXISTS icinga_hostescalations (
546   hostescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
547   instance_id bigint unsigned default 0,
548   config_type smallint default 0,
549   host_object_id bigint unsigned default 0,
550   timeperiod_object_id bigint unsigned default 0,
551   first_notification smallint default 0,
552   last_notification smallint default 0,
553   notification_interval double  default '0',
554   escalate_on_recovery smallint default 0,
555   escalate_on_down smallint default 0,
556   escalate_on_unreachable smallint default 0,
557   PRIMARY KEY  (hostescalation_id),
558   UNIQUE KEY instance_id (instance_id,config_type,host_object_id,timeperiod_object_id,first_notification,last_notification)
559 ) ENGINE=InnoDB  COMMENT='Host escalation definitions';
560
561 -- --------------------------------------------------------
562
563 --
564 -- Table structure for table icinga_hostescalation_contactgroups
565 --
566
567 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contactgroups (
568   hostescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
569   instance_id bigint unsigned default 0,
570   hostescalation_id bigint unsigned default 0,
571   contactgroup_object_id bigint unsigned default 0,
572   PRIMARY KEY  (hostescalation_contactgroup_id),
573   UNIQUE KEY instance_id (hostescalation_id,contactgroup_object_id)
574 ) ENGINE=InnoDB  COMMENT='Host escalation contact groups';
575
576 -- --------------------------------------------------------
577
578 --
579 -- Table structure for table icinga_hostescalation_contacts
580 --
581
582 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contacts (
583   hostescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
584   instance_id bigint unsigned default 0,
585   hostescalation_id bigint unsigned default 0,
586   contact_object_id bigint unsigned default 0,
587   PRIMARY KEY  (hostescalation_contact_id),
588   UNIQUE KEY instance_id (instance_id,hostescalation_id,contact_object_id)
589 ) ENGINE=InnoDB  COMMENT='Host escalation contacts';
590
591 -- --------------------------------------------------------
592
593 --
594 -- Table structure for table icinga_hostgroups
595 --
596
597 CREATE TABLE IF NOT EXISTS icinga_hostgroups (
598   hostgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
599   instance_id bigint unsigned default 0,
600   config_type smallint default 0,
601   hostgroup_object_id bigint unsigned default 0,
602   alias TEXT character set latin1  default '',
603   notes TEXT character set latin1  default NULL,
604   notes_url TEXT character set latin1  default NULL,
605   action_url TEXT character set latin1  default NULL,
606   PRIMARY KEY  (hostgroup_id),
607   UNIQUE KEY instance_id (instance_id,hostgroup_object_id)
608 ) ENGINE=InnoDB  COMMENT='Hostgroup definitions';
609
610 -- --------------------------------------------------------
611
612 --
613 -- Table structure for table icinga_hostgroup_members
614 --
615
616 CREATE TABLE IF NOT EXISTS icinga_hostgroup_members (
617   hostgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
618   instance_id bigint unsigned default 0,
619   hostgroup_id bigint unsigned default 0,
620   host_object_id bigint unsigned default 0,
621   PRIMARY KEY  (hostgroup_member_id)
622 ) ENGINE=InnoDB  COMMENT='Hostgroup members';
623
624 -- --------------------------------------------------------
625
626 --
627 -- Table structure for table icinga_hosts
628 --
629
630 CREATE TABLE IF NOT EXISTS icinga_hosts (
631   host_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
632   instance_id bigint unsigned default 0,
633   config_type smallint default 0,
634   host_object_id bigint unsigned default 0,
635   alias varchar(64) character set latin1  default '',
636   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
637   address varchar(128) character set latin1  default '',
638   address6 varchar(128) character set latin1  default '',
639   check_command_object_id bigint unsigned default 0,
640   check_command_args TEXT character set latin1  default '',
641   eventhandler_command_object_id bigint unsigned default 0,
642   eventhandler_command_args TEXT character set latin1  default '',
643   notification_timeperiod_object_id bigint unsigned default 0,
644   check_timeperiod_object_id bigint unsigned default 0,
645   failure_prediction_options varchar(128) character set latin1  default '',
646   check_interval double  default '0',
647   retry_interval double  default '0',
648   max_check_attempts smallint default 0,
649   first_notification_delay double  default '0',
650   notification_interval double  default '0',
651   notify_on_down smallint default 0,
652   notify_on_unreachable smallint default 0,
653   notify_on_recovery smallint default 0,
654   notify_on_flapping smallint default 0,
655   notify_on_downtime smallint default 0,
656   stalk_on_up smallint default 0,
657   stalk_on_down smallint default 0,
658   stalk_on_unreachable smallint default 0,
659   flap_detection_enabled smallint default 0,
660   flap_detection_on_up smallint default 0,
661   flap_detection_on_down smallint default 0,
662   flap_detection_on_unreachable smallint default 0,
663   low_flap_threshold double  default '0',
664   high_flap_threshold double  default '0',
665   process_performance_data smallint default 0,
666   freshness_checks_enabled smallint default 0,
667   freshness_threshold smallint default 0,
668   passive_checks_enabled smallint default 0,
669   event_handler_enabled smallint default 0,
670   active_checks_enabled smallint default 0,
671   retain_status_information smallint default 0,
672   retain_nonstatus_information smallint default 0,
673   notifications_enabled smallint default 0,
674   obsess_over_host smallint default 0,
675   failure_prediction_enabled smallint default 0,
676   notes TEXT character set latin1  default '',
677   notes_url TEXT character set latin1  default '',
678   action_url TEXT character set latin1  default '',
679   icon_image TEXT character set latin1  default '',
680   icon_image_alt TEXT character set latin1  default '',
681   vrml_image TEXT character set latin1  default '',
682   statusmap_image TEXT character set latin1  default '',
683   have_2d_coords smallint default 0,
684   x_2d smallint default 0,
685   y_2d smallint default 0,
686   have_3d_coords smallint default 0,
687   x_3d double  default '0',
688   y_3d double  default '0',
689   z_3d double  default '0',
690   PRIMARY KEY  (host_id),
691   UNIQUE KEY instance_id (instance_id,config_type,host_object_id),
692   KEY host_object_id (host_object_id)
693 ) ENGINE=InnoDB  COMMENT='Host definitions';
694
695 -- --------------------------------------------------------
696
697 --
698 -- Table structure for table icinga_hoststatus
699 --
700
701 CREATE TABLE IF NOT EXISTS icinga_hoststatus (
702   hoststatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
703   instance_id bigint unsigned default 0,
704   host_object_id bigint unsigned default 0,
705   status_update_time timestamp  default '0000-00-00 00:00:00',
706   output TEXT character set latin1  default '',
707   long_output TEXT  default '',
708   perfdata TEXT character set latin1  default '',
709   check_source TEXT character set latin1  default '',
710   current_state smallint default 0,
711   has_been_checked smallint default 0,
712   should_be_scheduled smallint default 0,
713   current_check_attempt smallint default 0,
714   max_check_attempts smallint default 0,
715   last_check timestamp  default '0000-00-00 00:00:00',
716   next_check timestamp  default '0000-00-00 00:00:00',
717   check_type smallint default 0,
718   last_state_change timestamp  default '0000-00-00 00:00:00',
719   last_hard_state_change timestamp  default '0000-00-00 00:00:00',
720   last_hard_state smallint default 0,
721   last_time_up timestamp  default '0000-00-00 00:00:00',
722   last_time_down timestamp  default '0000-00-00 00:00:00',
723   last_time_unreachable timestamp  default '0000-00-00 00:00:00',
724   state_type smallint default 0,
725   last_notification timestamp  default '0000-00-00 00:00:00',
726   next_notification timestamp  default '0000-00-00 00:00:00',
727   no_more_notifications smallint default 0,
728   notifications_enabled smallint default 0,
729   problem_has_been_acknowledged smallint default 0,
730   acknowledgement_type smallint default 0,
731   current_notification_number smallint default 0,
732   passive_checks_enabled smallint default 0,
733   active_checks_enabled smallint default 0,
734   event_handler_enabled smallint default 0,
735   flap_detection_enabled smallint default 0,
736   is_flapping smallint default 0,
737   percent_state_change double  default '0',
738   latency double  default '0',
739   execution_time double  default '0',
740   scheduled_downtime_depth smallint default 0,
741   failure_prediction_enabled smallint default 0,
742   process_performance_data smallint default 0,
743   obsess_over_host smallint default 0,
744   modified_host_attributes  int default 0,
745   event_handler TEXT character set latin1  default '',
746   check_command TEXT character set latin1  default '',
747   normal_check_interval double  default '0',
748   retry_check_interval double  default '0',
749   check_timeperiod_object_id bigint unsigned default 0,
750   is_reachable smallint default 0,
751   PRIMARY KEY  (hoststatus_id),
752   UNIQUE KEY object_id (host_object_id)
753 ) ENGINE=InnoDB  COMMENT='Current host status information';
754
755 -- --------------------------------------------------------
756
757 --
758 -- Table structure for table icinga_host_contactgroups
759 --
760
761 CREATE TABLE IF NOT EXISTS icinga_host_contactgroups (
762   host_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
763   instance_id bigint unsigned default 0,
764   host_id bigint unsigned default 0,
765   contactgroup_object_id bigint unsigned default 0,
766   PRIMARY KEY  (host_contactgroup_id)
767 ) ENGINE=InnoDB  COMMENT='Host contact groups';
768
769 -- --------------------------------------------------------
770
771 --
772 -- Table structure for table icinga_host_contacts
773 --
774
775 CREATE TABLE IF NOT EXISTS icinga_host_contacts (
776   host_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
777   instance_id bigint unsigned default 0,
778   host_id bigint unsigned default 0,
779   contact_object_id bigint unsigned default 0,
780   PRIMARY KEY  (host_contact_id)
781 ) ENGINE=InnoDB  COMMENT='Host contacts';
782
783 -- --------------------------------------------------------
784
785 --
786 -- Table structure for table icinga_host_parenthosts
787 --
788
789 CREATE TABLE IF NOT EXISTS icinga_host_parenthosts (
790   host_parenthost_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
791   instance_id bigint unsigned default 0,
792   host_id bigint unsigned default 0,
793   parent_host_object_id bigint unsigned default 0,
794   PRIMARY KEY  (host_parenthost_id)
795 ) ENGINE=InnoDB  COMMENT='Parent hosts';
796
797 -- --------------------------------------------------------
798
799 --
800 -- Table structure for table icinga_instances
801 --
802
803 CREATE TABLE IF NOT EXISTS icinga_instances (
804   instance_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
805   instance_name varchar(64) character set latin1  default '',
806   instance_description varchar(128) character set latin1  default '',
807   PRIMARY KEY  (instance_id)
808 ) ENGINE=InnoDB  COMMENT='Location names of various Icinga installations';
809
810 -- --------------------------------------------------------
811
812 --
813 -- Table structure for table icinga_logentries
814 --
815
816 CREATE TABLE IF NOT EXISTS icinga_logentries (
817   logentry_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
818   instance_id bigint unsigned default 0,
819   logentry_time timestamp  default '0000-00-00 00:00:00',
820   entry_time timestamp  default '0000-00-00 00:00:00',
821   entry_time_usec  int default 0,
822   logentry_type  int default 0,
823   logentry_data TEXT character set latin1  default '',
824   realtime_data smallint default 0,
825   inferred_data_extracted smallint default 0,
826   object_id bigint unsigned default NULL,
827   PRIMARY KEY  (logentry_id)
828 ) ENGINE=InnoDB COMMENT='Historical record of log entries';
829
830 -- --------------------------------------------------------
831
832 --
833 -- Table structure for table icinga_notifications
834 --
835
836 CREATE TABLE IF NOT EXISTS icinga_notifications (
837   notification_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
838   instance_id bigint unsigned default 0,
839   notification_type smallint default 0,
840   notification_reason smallint default 0,
841   object_id bigint unsigned default 0,
842   start_time timestamp  default '0000-00-00 00:00:00',
843   start_time_usec  int default 0,
844   end_time timestamp  default '0000-00-00 00:00:00',
845   end_time_usec  int default 0,
846   state smallint default 0,
847   output TEXT character set latin1  default '',
848   long_output TEXT  default '',
849   escalated smallint default 0,
850   contacts_notified smallint default 0,
851   PRIMARY KEY  (notification_id),
852   UNIQUE KEY instance_id (instance_id,object_id,start_time,start_time_usec)
853 ) ENGINE=InnoDB  COMMENT='Historical record of host and service notifications';
854
855 -- --------------------------------------------------------
856
857 --
858 -- Table structure for table icinga_objects
859 --
860
861 CREATE TABLE IF NOT EXISTS icinga_objects (
862   object_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
863   instance_id bigint unsigned default 0,
864   objecttype_id bigint unsigned default 0,
865   name1 varchar(128) character set latin1 collate latin1_general_cs  default '',
866   name2 varchar(128) character set latin1 collate latin1_general_cs default NULL,
867   is_active smallint default 0,
868   PRIMARY KEY  (object_id),
869   KEY objecttype_id (objecttype_id,name1,name2)
870 ) ENGINE=InnoDB  COMMENT='Current and historical objects of all kinds';
871
872 -- --------------------------------------------------------
873
874 --
875 -- Table structure for table icinga_processevents
876 --
877
878 CREATE TABLE IF NOT EXISTS icinga_processevents (
879   processevent_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
880   instance_id bigint unsigned default 0,
881   event_type smallint default 0,
882   event_time timestamp  default '0000-00-00 00:00:00',
883   event_time_usec  int default 0,
884   process_id bigint unsigned default 0,
885   program_name varchar(16) character set latin1  default '',
886   program_version varchar(20) character set latin1  default '',
887   program_date varchar(10) character set latin1  default '',
888   PRIMARY KEY  (processevent_id)
889 ) ENGINE=InnoDB  COMMENT='Historical Icinga process events';
890
891 -- --------------------------------------------------------
892
893 --
894 -- Table structure for table icinga_programstatus
895 --
896
897 CREATE TABLE IF NOT EXISTS icinga_programstatus (
898   programstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
899   instance_id bigint unsigned default 0,
900   program_version varchar(64) character set latin1 collate latin1_general_cs default NULL,
901   status_update_time timestamp  default '0000-00-00 00:00:00',
902   program_start_time timestamp  default '0000-00-00 00:00:00',
903   program_end_time timestamp  default '0000-00-00 00:00:00',
904   endpoint_name varchar(255) character set latin1 collate latin1_general_cs default NULL,
905   is_currently_running smallint default 0,
906   process_id bigint unsigned default 0,
907   daemon_mode smallint default 0,
908   last_command_check timestamp  default '0000-00-00 00:00:00',
909   last_log_rotation timestamp  default '0000-00-00 00:00:00',
910   notifications_enabled smallint default 0,
911   disable_notif_expire_time timestamp default '0000-00-00 00:00:00',
912   active_service_checks_enabled smallint default 0,
913   passive_service_checks_enabled smallint default 0,
914   active_host_checks_enabled smallint default 0,
915   passive_host_checks_enabled smallint default 0,
916   event_handlers_enabled smallint default 0,
917   flap_detection_enabled smallint default 0,
918   failure_prediction_enabled smallint default 0,
919   process_performance_data smallint default 0,
920   obsess_over_hosts smallint default 0,
921   obsess_over_services smallint default 0,
922   modified_host_attributes  int default 0,
923   modified_service_attributes  int default 0,
924   global_host_event_handler TEXT character set latin1  default '',
925   global_service_event_handler TEXT character set latin1  default '',
926   config_dump_in_progress smallint default 0,
927   PRIMARY KEY  (programstatus_id),
928   UNIQUE KEY instance_id (instance_id)
929 ) ENGINE=InnoDB  COMMENT='Current program status information';
930
931 -- --------------------------------------------------------
932
933 --
934 -- Table structure for table icinga_runtimevariables
935 --
936
937 CREATE TABLE IF NOT EXISTS icinga_runtimevariables (
938   runtimevariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
939   instance_id bigint unsigned default 0,
940   varname varchar(64) character set latin1  default '',
941   varvalue TEXT character set latin1  default '',
942   PRIMARY KEY  (runtimevariable_id)
943 ) ENGINE=InnoDB  COMMENT='Runtime variables from the Icinga daemon';
944
945 -- --------------------------------------------------------
946
947 --
948 -- Table structure for table icinga_scheduleddowntime
949 --
950
951 CREATE TABLE IF NOT EXISTS icinga_scheduleddowntime (
952   scheduleddowntime_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
953   instance_id bigint unsigned default 0,
954   downtime_type smallint default 0,
955   object_id bigint unsigned default 0,
956   entry_time timestamp  default '0000-00-00 00:00:00',
957   author_name varchar(64) character set latin1  default '',
958   comment_data TEXT character set latin1  default '',
959   internal_downtime_id bigint unsigned default 0,
960   triggered_by_id bigint unsigned default 0,
961   is_fixed smallint default 0,
962   duration bigint(20) default 0,
963   scheduled_start_time timestamp  default '0000-00-00 00:00:00',
964   scheduled_end_time timestamp  default '0000-00-00 00:00:00',
965   was_started smallint default 0,
966   actual_start_time timestamp  default '0000-00-00 00:00:00',
967   actual_start_time_usec  int default 0,
968   is_in_effect smallint default 0,
969   trigger_time timestamp  default '0000-00-00 00:00:00',
970   PRIMARY KEY  (scheduleddowntime_id),
971   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
972 ) ENGINE=InnoDB COMMENT='Current scheduled host and service downtime';
973
974 -- --------------------------------------------------------
975
976 --
977 -- Table structure for table icinga_servicechecks
978 --
979
980 CREATE TABLE IF NOT EXISTS icinga_servicechecks (
981   servicecheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
982   instance_id bigint unsigned default 0,
983   service_object_id bigint unsigned default 0,
984   check_type smallint default 0,
985   current_check_attempt smallint default 0,
986   max_check_attempts smallint default 0,
987   state smallint default 0,
988   state_type smallint default 0,
989   start_time timestamp  default '0000-00-00 00:00:00',
990   start_time_usec  int default 0,
991   end_time timestamp  default '0000-00-00 00:00:00',
992   end_time_usec  int default 0,
993   command_object_id bigint unsigned default 0,
994   command_args TEXT character set latin1  default '',
995   command_line TEXT character set latin1  default '',
996   timeout smallint default 0,
997   early_timeout smallint default 0,
998   execution_time double  default '0',
999   latency double  default '0',
1000   return_code smallint default 0,
1001   output TEXT character set latin1  default '',
1002   long_output TEXT  default '',
1003   perfdata TEXT character set latin1  default '',
1004   PRIMARY KEY  (servicecheck_id)
1005 ) ENGINE=InnoDB  COMMENT='Historical service checks';
1006
1007 -- --------------------------------------------------------
1008
1009 --
1010 -- Table structure for table icinga_servicedependencies
1011 --
1012
1013 CREATE TABLE IF NOT EXISTS icinga_servicedependencies (
1014   servicedependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1015   instance_id bigint unsigned default 0,
1016   config_type smallint default 0,
1017   service_object_id bigint unsigned default 0,
1018   dependent_service_object_id bigint unsigned default 0,
1019   dependency_type smallint default 0,
1020   inherits_parent smallint default 0,
1021   timeperiod_object_id bigint unsigned default 0,
1022   fail_on_ok smallint default 0,
1023   fail_on_warning smallint default 0,
1024   fail_on_unknown smallint default 0,
1025   fail_on_critical smallint default 0,
1026   PRIMARY KEY  (servicedependency_id),
1027   UNIQUE KEY instance_id (instance_id,config_type,service_object_id,dependent_service_object_id,dependency_type,inherits_parent,fail_on_ok,fail_on_warning,fail_on_unknown,fail_on_critical)
1028 ) ENGINE=InnoDB COMMENT='Service dependency definitions';
1029
1030 -- --------------------------------------------------------
1031
1032 --
1033 -- Table structure for table icinga_serviceescalations
1034 --
1035
1036 CREATE TABLE IF NOT EXISTS icinga_serviceescalations (
1037   serviceescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1038   instance_id bigint unsigned default 0,
1039   config_type smallint default 0,
1040   service_object_id bigint unsigned default 0,
1041   timeperiod_object_id bigint unsigned default 0,
1042   first_notification smallint default 0,
1043   last_notification smallint default 0,
1044   notification_interval double  default '0',
1045   escalate_on_recovery smallint default 0,
1046   escalate_on_warning smallint default 0,
1047   escalate_on_unknown smallint default 0,
1048   escalate_on_critical smallint default 0,
1049   PRIMARY KEY  (serviceescalation_id),
1050   UNIQUE KEY instance_id (instance_id,config_type,service_object_id,timeperiod_object_id,first_notification,last_notification)
1051 ) ENGINE=InnoDB  COMMENT='Service escalation definitions';
1052
1053 -- --------------------------------------------------------
1054
1055 --
1056 -- Table structure for table icinga_serviceescalation_contactgroups
1057 --
1058
1059 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contactgroups (
1060   serviceescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1061   instance_id bigint unsigned default 0,
1062   serviceescalation_id bigint unsigned default 0,
1063   contactgroup_object_id bigint unsigned default 0,
1064   PRIMARY KEY  (serviceescalation_contactgroup_id),
1065   UNIQUE KEY instance_id (serviceescalation_id,contactgroup_object_id)
1066 ) ENGINE=InnoDB  COMMENT='Service escalation contact groups';
1067
1068 -- --------------------------------------------------------
1069
1070 --
1071 -- Table structure for table icinga_serviceescalation_contacts
1072 --
1073
1074 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contacts (
1075   serviceescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1076   instance_id bigint unsigned default 0,
1077   serviceescalation_id bigint unsigned default 0,
1078   contact_object_id bigint unsigned default 0,
1079   PRIMARY KEY  (serviceescalation_contact_id),
1080   UNIQUE KEY instance_id (instance_id,serviceescalation_id,contact_object_id)
1081 ) ENGINE=InnoDB  COMMENT='Service escalation contacts';
1082
1083 -- --------------------------------------------------------
1084
1085 --
1086 -- Table structure for table icinga_servicegroups
1087 --
1088
1089 CREATE TABLE IF NOT EXISTS icinga_servicegroups (
1090   servicegroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1091   instance_id bigint unsigned default 0,
1092   config_type smallint default 0,
1093   servicegroup_object_id bigint unsigned default 0,
1094   alias TEXT character set latin1  default '',
1095   notes TEXT character set latin1  default NULL,
1096   notes_url TEXT character set latin1  default NULL,
1097   action_url TEXT character set latin1  default NULL,
1098   PRIMARY KEY  (servicegroup_id),
1099   UNIQUE KEY instance_id (instance_id,config_type,servicegroup_object_id)
1100 ) ENGINE=InnoDB  COMMENT='Servicegroup definitions';
1101
1102 -- --------------------------------------------------------
1103
1104 --
1105 -- Table structure for table icinga_servicegroup_members
1106 --
1107
1108 CREATE TABLE IF NOT EXISTS icinga_servicegroup_members (
1109   servicegroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1110   instance_id bigint unsigned default 0,
1111   servicegroup_id bigint unsigned default 0,
1112   service_object_id bigint unsigned default 0,
1113   PRIMARY KEY  (servicegroup_member_id)
1114 ) ENGINE=InnoDB  COMMENT='Servicegroup members';
1115
1116 -- --------------------------------------------------------
1117
1118 --
1119 -- Table structure for table icinga_services
1120 --
1121
1122 CREATE TABLE IF NOT EXISTS icinga_services (
1123   service_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1124   instance_id bigint unsigned default 0,
1125   config_type smallint default 0,
1126   host_object_id bigint unsigned default 0,
1127   service_object_id bigint unsigned default 0,
1128   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
1129   check_command_object_id bigint unsigned default 0,
1130   check_command_args TEXT character set latin1  default '',
1131   eventhandler_command_object_id bigint unsigned default 0,
1132   eventhandler_command_args TEXT character set latin1  default '',
1133   notification_timeperiod_object_id bigint unsigned default 0,
1134   check_timeperiod_object_id bigint unsigned default 0,
1135   failure_prediction_options varchar(64) character set latin1  default '',
1136   check_interval double  default '0',
1137   retry_interval double  default '0',
1138   max_check_attempts smallint default 0,
1139   first_notification_delay double  default '0',
1140   notification_interval double  default '0',
1141   notify_on_warning smallint default 0,
1142   notify_on_unknown smallint default 0,
1143   notify_on_critical smallint default 0,
1144   notify_on_recovery smallint default 0,
1145   notify_on_flapping smallint default 0,
1146   notify_on_downtime smallint default 0,
1147   stalk_on_ok smallint default 0,
1148   stalk_on_warning smallint default 0,
1149   stalk_on_unknown smallint default 0,
1150   stalk_on_critical smallint default 0,
1151   is_volatile smallint default 0,
1152   flap_detection_enabled smallint default 0,
1153   flap_detection_on_ok smallint default 0,
1154   flap_detection_on_warning smallint default 0,
1155   flap_detection_on_unknown smallint default 0,
1156   flap_detection_on_critical smallint default 0,
1157   low_flap_threshold double  default '0',
1158   high_flap_threshold double  default '0',
1159   process_performance_data smallint default 0,
1160   freshness_checks_enabled smallint default 0,
1161   freshness_threshold smallint default 0,
1162   passive_checks_enabled smallint default 0,
1163   event_handler_enabled smallint default 0,
1164   active_checks_enabled smallint default 0,
1165   retain_status_information smallint default 0,
1166   retain_nonstatus_information smallint default 0,
1167   notifications_enabled smallint default 0,
1168   obsess_over_service smallint default 0,
1169   failure_prediction_enabled smallint default 0,
1170   notes TEXT character set latin1  default '',
1171   notes_url TEXT character set latin1  default '',
1172   action_url TEXT character set latin1  default '',
1173   icon_image TEXT character set latin1  default '',
1174   icon_image_alt TEXT character set latin1  default '',
1175   PRIMARY KEY  (service_id),
1176   UNIQUE KEY instance_id (instance_id,config_type,service_object_id),
1177   KEY service_object_id (service_object_id)
1178 ) ENGINE=InnoDB  COMMENT='Service definitions';
1179
1180 -- --------------------------------------------------------
1181
1182 --
1183 -- Table structure for table icinga_servicestatus
1184 --
1185
1186 CREATE TABLE IF NOT EXISTS icinga_servicestatus (
1187   servicestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1188   instance_id bigint unsigned default 0,
1189   service_object_id bigint unsigned default 0,
1190   status_update_time timestamp  default '0000-00-00 00:00:00',
1191   output TEXT character set latin1  default '',
1192   long_output TEXT  default '',
1193   perfdata TEXT character set latin1  default '',
1194   check_source TEXT character set latin1  default '',
1195   current_state smallint default 0,
1196   has_been_checked smallint default 0,
1197   should_be_scheduled smallint default 0,
1198   current_check_attempt smallint default 0,
1199   max_check_attempts smallint default 0,
1200   last_check timestamp  default '0000-00-00 00:00:00',
1201   next_check timestamp  default '0000-00-00 00:00:00',
1202   check_type smallint default 0,
1203   last_state_change timestamp  default '0000-00-00 00:00:00',
1204   last_hard_state_change timestamp  default '0000-00-00 00:00:00',
1205   last_hard_state smallint default 0,
1206   last_time_ok timestamp  default '0000-00-00 00:00:00',
1207   last_time_warning timestamp  default '0000-00-00 00:00:00',
1208   last_time_unknown timestamp  default '0000-00-00 00:00:00',
1209   last_time_critical timestamp  default '0000-00-00 00:00:00',
1210   state_type smallint default 0,
1211   last_notification timestamp  default '0000-00-00 00:00:00',
1212   next_notification timestamp  default '0000-00-00 00:00:00',
1213   no_more_notifications smallint default 0,
1214   notifications_enabled smallint default 0,
1215   problem_has_been_acknowledged smallint default 0,
1216   acknowledgement_type smallint default 0,
1217   current_notification_number smallint default 0,
1218   passive_checks_enabled smallint default 0,
1219   active_checks_enabled smallint default 0,
1220   event_handler_enabled smallint default 0,
1221   flap_detection_enabled smallint default 0,
1222   is_flapping smallint default 0,
1223   percent_state_change double  default '0',
1224   latency double  default '0',
1225   execution_time double  default '0',
1226   scheduled_downtime_depth smallint default 0,
1227   failure_prediction_enabled smallint default 0,
1228   process_performance_data smallint default 0,
1229   obsess_over_service smallint default 0,
1230   modified_service_attributes  int default 0,
1231   event_handler TEXT character set latin1  default '',
1232   check_command TEXT character set latin1  default '',
1233   normal_check_interval double  default '0',
1234   retry_check_interval double  default '0',
1235   check_timeperiod_object_id bigint unsigned default 0,
1236   is_reachable smallint default 0,
1237   PRIMARY KEY  (servicestatus_id),
1238   UNIQUE KEY object_id (service_object_id)
1239 ) ENGINE=InnoDB  COMMENT='Current service status information';
1240
1241 -- --------------------------------------------------------
1242
1243 --
1244 -- Table structure for table icinga_service_contactgroups
1245 --
1246
1247 CREATE TABLE IF NOT EXISTS icinga_service_contactgroups (
1248   service_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1249   instance_id bigint unsigned default 0,
1250   service_id bigint unsigned default 0,
1251   contactgroup_object_id bigint unsigned default 0,
1252   PRIMARY KEY  (service_contactgroup_id)
1253 ) ENGINE=InnoDB  COMMENT='Service contact groups';
1254
1255 -- --------------------------------------------------------
1256
1257 --
1258 -- Table structure for table icinga_service_contacts
1259 --
1260
1261 CREATE TABLE IF NOT EXISTS icinga_service_contacts (
1262   service_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1263   instance_id bigint unsigned default 0,
1264   service_id bigint unsigned default 0,
1265   contact_object_id bigint unsigned default 0,
1266   PRIMARY KEY  (service_contact_id)
1267 ) ENGINE=InnoDB  COMMENT='Service contacts';
1268
1269 -- --------------------------------------------------------
1270
1271 --
1272 -- Table structure for table icinga_statehistory
1273 --
1274
1275 CREATE TABLE IF NOT EXISTS icinga_statehistory (
1276   statehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1277   instance_id bigint unsigned default 0,
1278   state_time timestamp  default '0000-00-00 00:00:00',
1279   state_time_usec  int default 0,
1280   object_id bigint unsigned default 0,
1281   state_change smallint default 0,
1282   state smallint default 0,
1283   state_type smallint default 0,
1284   current_check_attempt smallint default 0,
1285   max_check_attempts smallint default 0,
1286   last_state smallint default 0,
1287   last_hard_state smallint default 0,
1288   output TEXT character set latin1  default '',
1289   long_output TEXT  default '',
1290   check_source varchar(255) character set latin1 default NULL,
1291   PRIMARY KEY  (statehistory_id)
1292 ) ENGINE=InnoDB COMMENT='Historical host and service state changes';
1293
1294 -- --------------------------------------------------------
1295
1296 --
1297 -- Table structure for table icinga_systemcommands
1298 --
1299
1300 CREATE TABLE IF NOT EXISTS icinga_systemcommands (
1301   systemcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1302   instance_id bigint unsigned default 0,
1303   start_time timestamp  default '0000-00-00 00:00:00',
1304   start_time_usec  int default 0,
1305   end_time timestamp  default '0000-00-00 00:00:00',
1306   end_time_usec  int default 0,
1307   command_line TEXT character set latin1  default '',
1308   timeout smallint default 0,
1309   early_timeout smallint default 0,
1310   execution_time double  default '0',
1311   return_code smallint default 0,
1312   output TEXT character set latin1  default '',
1313   long_output TEXT  default '',
1314   PRIMARY KEY  (systemcommand_id),
1315   UNIQUE KEY instance_id (instance_id,start_time,start_time_usec)
1316 ) ENGINE=InnoDB  COMMENT='Historical system commands that are executed';
1317
1318 -- --------------------------------------------------------
1319
1320 --
1321 -- Table structure for table icinga_timeperiods
1322 --
1323
1324 CREATE TABLE IF NOT EXISTS icinga_timeperiods (
1325   timeperiod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1326   instance_id bigint unsigned default 0,
1327   config_type smallint default 0,
1328   timeperiod_object_id bigint unsigned default 0,
1329   alias TEXT character set latin1  default '',
1330   PRIMARY KEY  (timeperiod_id),
1331   UNIQUE KEY instance_id (instance_id,config_type,timeperiod_object_id)
1332 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1333
1334 -- --------------------------------------------------------
1335
1336 --
1337 -- Table structure for table icinga_timeperiod_timeranges
1338 --
1339
1340 CREATE TABLE IF NOT EXISTS icinga_timeperiod_timeranges (
1341   timeperiod_timerange_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1342   instance_id bigint unsigned default 0,
1343   timeperiod_id bigint unsigned default 0,
1344   day smallint default 0,
1345   start_sec  int default 0,
1346   end_sec  int default 0,
1347   PRIMARY KEY  (timeperiod_timerange_id)
1348 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1349
1350
1351 -- --------------------------------------------------------
1352 -- Icinga 2 specific schema extensions
1353 -- --------------------------------------------------------
1354
1355 --
1356 -- Table structure for table icinga_endpoints
1357 --
1358
1359 CREATE TABLE IF NOT EXISTS icinga_endpoints (
1360   endpoint_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1361   instance_id bigint unsigned default 0,
1362   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1363   config_type smallint(6) DEFAULT '0',
1364   identity varchar(255) DEFAULT NULL,
1365   node varchar(255) DEFAULT NULL,
1366   PRIMARY KEY  (endpoint_id)
1367 ) ENGINE=InnoDB COMMENT='Endpoint configuration';
1368
1369 -- --------------------------------------------------------
1370
1371 --
1372 -- Table structure for table icinga_endpointstatus
1373 --
1374
1375 CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
1376   endpointstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1377   instance_id bigint unsigned default 0,
1378   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1379   status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
1380   identity varchar(255) DEFAULT NULL,
1381   node varchar(255) DEFAULT NULL,
1382   is_connected smallint(6),
1383   PRIMARY KEY  (endpointstatus_id)
1384 ) ENGINE=InnoDB COMMENT='Endpoint status';
1385
1386
1387 ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
1388 ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
1389 ALTER TABLE icinga_contactstatus ADD COLUMN endpoint_object_id bigint default NULL;
1390 ALTER TABLE icinga_programstatus ADD COLUMN endpoint_object_id bigint default NULL;
1391 ALTER TABLE icinga_comments ADD COLUMN endpoint_object_id bigint default NULL;
1392 ALTER TABLE icinga_scheduleddowntime ADD COLUMN endpoint_object_id bigint default NULL;
1393 ALTER TABLE icinga_runtimevariables ADD COLUMN endpoint_object_id bigint default NULL;
1394 ALTER TABLE icinga_customvariablestatus ADD COLUMN endpoint_object_id bigint default NULL;
1395
1396 ALTER TABLE icinga_acknowledgements ADD COLUMN endpoint_object_id bigint default NULL;
1397 ALTER TABLE icinga_commenthistory ADD COLUMN endpoint_object_id bigint default NULL;
1398 ALTER TABLE icinga_contactnotifications ADD COLUMN endpoint_object_id bigint default NULL;
1399 ALTER TABLE icinga_downtimehistory ADD COLUMN endpoint_object_id bigint default NULL;
1400 ALTER TABLE icinga_eventhandlers ADD COLUMN endpoint_object_id bigint default NULL;
1401 ALTER TABLE icinga_externalcommands ADD COLUMN endpoint_object_id bigint default NULL;
1402 ALTER TABLE icinga_flappinghistory ADD COLUMN endpoint_object_id bigint default NULL;
1403 ALTER TABLE icinga_hostchecks ADD COLUMN endpoint_object_id bigint default NULL;
1404 ALTER TABLE icinga_logentries ADD COLUMN endpoint_object_id bigint default NULL;
1405 ALTER TABLE icinga_notifications ADD COLUMN endpoint_object_id bigint default NULL;
1406 ALTER TABLE icinga_processevents ADD COLUMN endpoint_object_id bigint default NULL;
1407 ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NULL;
1408 ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
1409 ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;
1410
1411
1412 -- -----------------------------------------
1413 -- add index (delete)
1414 -- -----------------------------------------
1415
1416 -- for periodic delete 
1417 -- instance_id and
1418 -- SYSTEMCOMMANDS, SERVICECHECKS, HOSTCHECKS, EVENTHANDLERS  => start_time
1419 -- EXTERNALCOMMANDS => entry_time
1420
1421 -- instance_id
1422 CREATE INDEX systemcommands_i_id_idx on icinga_systemcommands(instance_id);
1423 CREATE INDEX servicechecks_i_id_idx on icinga_servicechecks(instance_id);
1424 CREATE INDEX hostchecks_i_id_idx on icinga_hostchecks(instance_id);
1425 CREATE INDEX eventhandlers_i_id_idx on icinga_eventhandlers(instance_id);
1426 CREATE INDEX externalcommands_i_id_idx on icinga_externalcommands(instance_id);
1427
1428 -- time
1429 CREATE INDEX systemcommands_time_id_idx on icinga_systemcommands(start_time);
1430 CREATE INDEX servicechecks_time_id_idx on icinga_servicechecks(start_time);
1431 CREATE INDEX hostchecks_time_id_idx on icinga_hostchecks(start_time);
1432 CREATE INDEX eventhandlers_time_id_idx on icinga_eventhandlers(start_time);
1433 CREATE INDEX externalcommands_time_id_idx on icinga_externalcommands(entry_time);
1434
1435
1436 -- for starting cleanup - referenced in dbhandler.c:882
1437 -- instance_id only
1438
1439 -- realtime data
1440 CREATE INDEX programstatus_i_id_idx on icinga_programstatus(instance_id);
1441 CREATE INDEX hoststatus_i_id_idx on icinga_hoststatus(instance_id);
1442 CREATE INDEX servicestatus_i_id_idx on icinga_servicestatus(instance_id);
1443 CREATE INDEX contactstatus_i_id_idx on icinga_contactstatus(instance_id);
1444 CREATE INDEX comments_i_id_idx on icinga_comments(instance_id);
1445 CREATE INDEX scheduleddowntime_i_id_idx on icinga_scheduleddowntime(instance_id);
1446 CREATE INDEX runtimevariables_i_id_idx on icinga_runtimevariables(instance_id);
1447 CREATE INDEX customvariablestatus_i_id_idx on icinga_customvariablestatus(instance_id);
1448
1449 -- config data
1450 CREATE INDEX configfiles_i_id_idx on icinga_configfiles(instance_id);
1451 CREATE INDEX configfilevariables_i_id_idx on icinga_configfilevariables(instance_id);
1452 CREATE INDEX customvariables_i_id_idx on icinga_customvariables(instance_id);
1453 CREATE INDEX commands_i_id_idx on icinga_commands(instance_id);
1454 CREATE INDEX timeperiods_i_id_idx on icinga_timeperiods(instance_id);
1455 CREATE INDEX timeperiod_timeranges_i_id_idx on icinga_timeperiod_timeranges(instance_id);
1456 CREATE INDEX contactgroups_i_id_idx on icinga_contactgroups(instance_id);
1457 CREATE INDEX contactgroup_members_i_id_idx on icinga_contactgroup_members(instance_id);
1458 CREATE INDEX hostgroups_i_id_idx on icinga_hostgroups(instance_id);
1459 CREATE INDEX hostgroup_members_i_id_idx on icinga_hostgroup_members(instance_id);
1460 CREATE INDEX servicegroups_i_id_idx on icinga_servicegroups(instance_id);
1461 CREATE INDEX servicegroup_members_i_id_idx on icinga_servicegroup_members(instance_id);
1462 CREATE INDEX hostesc_i_id_idx on icinga_hostescalations(instance_id);
1463 CREATE INDEX hostesc_contacts_i_id_idx on icinga_hostescalation_contacts(instance_id);
1464 CREATE INDEX serviceesc_i_id_idx on icinga_serviceescalations(instance_id);
1465 CREATE INDEX serviceesc_contacts_i_id_idx on icinga_serviceescalation_contacts(instance_id);
1466 CREATE INDEX hostdependencies_i_id_idx on icinga_hostdependencies(instance_id);
1467 CREATE INDEX contacts_i_id_idx on icinga_contacts(instance_id);
1468 CREATE INDEX contact_addresses_i_id_idx on icinga_contact_addresses(instance_id);
1469 CREATE INDEX contact_notifcommands_i_id_idx on icinga_contact_notificationcommands(instance_id);
1470 CREATE INDEX hosts_i_id_idx on icinga_hosts(instance_id);
1471 CREATE INDEX host_parenthosts_i_id_idx on icinga_host_parenthosts(instance_id);
1472 CREATE INDEX host_contacts_i_id_idx on icinga_host_contacts(instance_id);
1473 CREATE INDEX services_i_id_idx on icinga_services(instance_id);
1474 CREATE INDEX service_contacts_i_id_idx on icinga_service_contacts(instance_id);
1475 CREATE INDEX service_contactgroups_i_id_idx on icinga_service_contactgroups(instance_id);
1476 CREATE INDEX host_contactgroups_i_id_idx on icinga_host_contactgroups(instance_id);
1477 CREATE INDEX hostesc_cgroups_i_id_idx on icinga_hostescalation_contactgroups(instance_id);
1478 CREATE INDEX serviceesc_cgroups_i_id_idx on icinga_serviceescalation_contactgroups(instance_id);
1479
1480 -- -----------------------------------------
1481 -- more index stuff (WHERE clauses)
1482 -- -----------------------------------------
1483
1484 -- hosts
1485 CREATE INDEX hosts_host_object_id_idx on icinga_hosts(host_object_id);
1486
1487 -- hoststatus
1488 CREATE INDEX hoststatus_stat_upd_time_idx on icinga_hoststatus(status_update_time);
1489 CREATE INDEX hoststatus_current_state_idx on icinga_hoststatus(current_state);
1490 CREATE INDEX hoststatus_check_type_idx on icinga_hoststatus(check_type);
1491 CREATE INDEX hoststatus_state_type_idx on icinga_hoststatus(state_type);
1492 CREATE INDEX hoststatus_last_state_chg_idx on icinga_hoststatus(last_state_change);
1493 CREATE INDEX hoststatus_notif_enabled_idx on icinga_hoststatus(notifications_enabled);
1494 CREATE INDEX hoststatus_problem_ack_idx on icinga_hoststatus(problem_has_been_acknowledged);
1495 CREATE INDEX hoststatus_act_chks_en_idx on icinga_hoststatus(active_checks_enabled);
1496 CREATE INDEX hoststatus_pas_chks_en_idx on icinga_hoststatus(passive_checks_enabled);
1497 CREATE INDEX hoststatus_event_hdl_en_idx on icinga_hoststatus(event_handler_enabled);
1498 CREATE INDEX hoststatus_flap_det_en_idx on icinga_hoststatus(flap_detection_enabled);
1499 CREATE INDEX hoststatus_is_flapping_idx on icinga_hoststatus(is_flapping);
1500 CREATE INDEX hoststatus_p_state_chg_idx on icinga_hoststatus(percent_state_change);
1501 CREATE INDEX hoststatus_latency_idx on icinga_hoststatus(latency);
1502 CREATE INDEX hoststatus_ex_time_idx on icinga_hoststatus(execution_time);
1503 CREATE INDEX hoststatus_sch_downt_d_idx on icinga_hoststatus(scheduled_downtime_depth);
1504
1505 -- services
1506 CREATE INDEX services_host_object_id_idx on icinga_services(host_object_id);
1507
1508 -- servicestatus
1509 CREATE INDEX srvcstatus_stat_upd_time_idx on icinga_servicestatus(status_update_time);
1510 CREATE INDEX srvcstatus_current_state_idx on icinga_servicestatus(current_state);
1511 CREATE INDEX srvcstatus_check_type_idx on icinga_servicestatus(check_type);
1512 CREATE INDEX srvcstatus_state_type_idx on icinga_servicestatus(state_type);
1513 CREATE INDEX srvcstatus_last_state_chg_idx on icinga_servicestatus(last_state_change);
1514 CREATE INDEX srvcstatus_notif_enabled_idx on icinga_servicestatus(notifications_enabled);
1515 CREATE INDEX srvcstatus_problem_ack_idx on icinga_servicestatus(problem_has_been_acknowledged);
1516 CREATE INDEX srvcstatus_act_chks_en_idx on icinga_servicestatus(active_checks_enabled);
1517 CREATE INDEX srvcstatus_pas_chks_en_idx on icinga_servicestatus(passive_checks_enabled);
1518 CREATE INDEX srvcstatus_event_hdl_en_idx on icinga_servicestatus(event_handler_enabled);
1519 CREATE INDEX srvcstatus_flap_det_en_idx on icinga_servicestatus(flap_detection_enabled);
1520 CREATE INDEX srvcstatus_is_flapping_idx on icinga_servicestatus(is_flapping);
1521 CREATE INDEX srvcstatus_p_state_chg_idx on icinga_servicestatus(percent_state_change);
1522 CREATE INDEX srvcstatus_latency_idx on icinga_servicestatus(latency);
1523 CREATE INDEX srvcstatus_ex_time_idx on icinga_servicestatus(execution_time);
1524 CREATE INDEX srvcstatus_sch_downt_d_idx on icinga_servicestatus(scheduled_downtime_depth);
1525
1526 -- hostchecks
1527 CREATE INDEX hostchks_h_obj_id_idx on icinga_hostchecks(host_object_id);
1528
1529 -- servicechecks
1530 CREATE INDEX servicechks_s_obj_id_idx on icinga_servicechecks(service_object_id);
1531
1532 -- objects
1533 CREATE INDEX objects_objtype_id_idx ON icinga_objects(objecttype_id);
1534 CREATE INDEX objects_name1_idx ON icinga_objects(name1);
1535 CREATE INDEX objects_name2_idx ON icinga_objects(name2);
1536 CREATE INDEX objects_inst_id_idx ON icinga_objects(instance_id);
1537
1538 -- instances
1539 -- CREATE INDEX instances_name_idx on icinga_instances(instance_name);
1540
1541 -- logentries
1542 -- CREATE INDEX loge_instance_id_idx on icinga_logentries(instance_id);
1543 -- #236
1544 CREATE INDEX loge_time_idx on icinga_logentries(logentry_time);
1545 -- CREATE INDEX loge_data_idx on icinga_logentries(logentry_data);
1546 CREATE INDEX loge_inst_id_time_idx on icinga_logentries (instance_id ASC, logentry_time DESC);
1547
1548 -- commenthistory
1549 -- CREATE INDEX c_hist_instance_id_idx on icinga_logentries(instance_id);
1550 -- CREATE INDEX c_hist_c_time_idx on icinga_logentries(comment_time);
1551 -- CREATE INDEX c_hist_i_c_id_idx on icinga_logentries(internal_comment_id);
1552
1553 -- downtimehistory
1554 -- CREATE INDEX d_t_hist_nstance_id_idx on icinga_downtimehistory(instance_id);
1555 -- CREATE INDEX d_t_hist_type_idx on icinga_downtimehistory(downtime_type);
1556 -- CREATE INDEX d_t_hist_object_id_idx on icinga_downtimehistory(object_id);
1557 -- CREATE INDEX d_t_hist_entry_time_idx on icinga_downtimehistory(entry_time);
1558 -- CREATE INDEX d_t_hist_sched_start_idx on icinga_downtimehistory(scheduled_start_time);
1559 -- CREATE INDEX d_t_hist_sched_end_idx on icinga_downtimehistory(scheduled_end_time);
1560
1561 -- scheduleddowntime
1562 -- CREATE INDEX sched_d_t_downtime_type_idx on icinga_scheduleddowntime(downtime_type);
1563 -- CREATE INDEX sched_d_t_object_id_idx on icinga_scheduleddowntime(object_id);
1564 -- CREATE INDEX sched_d_t_entry_time_idx on icinga_scheduleddowntime(entry_time);
1565 -- CREATE INDEX sched_d_t_start_time_idx on icinga_scheduleddowntime(scheduled_start_time);
1566 -- CREATE INDEX sched_d_t_end_time_idx on icinga_scheduleddowntime(scheduled_end_time);
1567
1568 -- statehistory
1569 CREATE INDEX statehist_i_id_o_id_s_ty_s_ti on icinga_statehistory(instance_id, object_id, state_type, state_time);
1570 --#2274
1571 create index statehist_state_idx on icinga_statehistory(object_id,state);
1572
1573
1574 -- Icinga Web Notifications
1575 CREATE INDEX notification_idx ON icinga_notifications(notification_type, object_id, start_time);
1576 CREATE INDEX notification_object_id_idx ON icinga_notifications(object_id);
1577 CREATE INDEX contact_notification_idx ON icinga_contactnotifications(notification_id, contact_object_id);
1578 CREATE INDEX contacts_object_id_idx ON icinga_contacts(contact_object_id);
1579 CREATE INDEX contact_notif_meth_notif_idx ON icinga_contactnotificationmethods(contactnotification_id, command_object_id);
1580 CREATE INDEX command_object_idx ON icinga_commands(object_id); 
1581 CREATE INDEX services_combined_object_idx ON icinga_services(service_object_id, host_object_id);
1582
1583
1584 -- #2618
1585 CREATE INDEX cntgrpmbrs_cgid_coid ON icinga_contactgroup_members (contactgroup_id,contact_object_id);
1586 CREATE INDEX hstgrpmbrs_hgid_hoid ON icinga_hostgroup_members (hostgroup_id,host_object_id);
1587 CREATE INDEX hstcntgrps_hid_cgoid ON icinga_host_contactgroups (host_id,contactgroup_object_id);
1588 CREATE INDEX hstprnthsts_hid_phoid ON icinga_host_parenthosts (host_id,parent_host_object_id);
1589 CREATE INDEX runtimevars_iid_varn ON icinga_runtimevariables (instance_id,varname);
1590 CREATE INDEX sgmbrs_sgid_soid ON icinga_servicegroup_members (servicegroup_id,service_object_id);
1591 CREATE INDEX scgrps_sid_cgoid ON icinga_service_contactgroups (service_id,contactgroup_object_id);
1592 CREATE INDEX tperiod_tid_d_ss_es ON icinga_timeperiod_timeranges (timeperiod_id,day,start_sec,end_sec);
1593
1594 -- #3649
1595 CREATE INDEX sla_idx_sthist ON icinga_statehistory (object_id, state_time DESC);
1596 CREATE INDEX sla_idx_dohist ON icinga_downtimehistory (object_id, actual_start_time, actual_end_time);
1597 CREATE INDEX sla_idx_obj ON icinga_objects (objecttype_id, is_active, name1);
1598
1599 -- #4985
1600 CREATE INDEX commenthistory_delete_idx ON icinga_commenthistory (instance_id, comment_time, internal_comment_id);
1601
1602 -- -----------------------------------------
1603 -- set dbversion
1604 -- -----------------------------------------
1605 INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.11.8', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.11.8', modify_time=NOW();
1606
1607