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