#include <boost/thread/once.hpp>
#include <boost/thread/mutex.hpp>
-#define IDO_CURRENT_SCHEMA_VERSION "1.14.2"
+#define IDO_CURRENT_SCHEMA_VERSION "1.14.3"
#define IDO_COMPAT_SCHEMA_VERSION "1.14.2"
namespace icinga
query1.Type = DbQueryDelete;
query1.Category = DbCatDowntime;
query1.WhereCriteria = new Dictionary();
+
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-- mysql.sql
-- DB definition for IDO MySQL
--
--- Copyright (c) 2009-2016 Icinga Development Team (https://www.icinga.com/)
+-- Copyright (c) 2009-2017 Icinga Development Team (https://www.icinga.com/)
--
-- -- --------------------------------------------------------
CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_id);
CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id);
+-- #5458
+CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+
+
-- -----------------------------------------
-- set dbversion
-- -----------------------------------------
-INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.2', NOW(), NOW())
-ON DUPLICATE KEY UPDATE version='1.14.2', modify_time=NOW();
+INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW())
+ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW();
--- /dev/null
+-- -----------------------------------------
+-- upgrade path for Icinga 2.8.0
+--
+-- -----------------------------------------
+-- Copyright (c) 2017 Icinga Development Team (https://www.icinga.com)
+--
+-- Please check https://docs.icinga.com for upgrading information!
+-- -----------------------------------------
+
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
+-- -----------------------------------------
+-- #5458 IDO: Improve downtime removal/cancel
+-- -----------------------------------------
+
+CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+
+-- -----------------------------------------
+-- set dbversion
+-- -----------------------------------------
+INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW();
-- pgsql.sql
-- DB definition for IDO Postgresql
--
--- Copyright (c) 2009-2016 Icinga Development Team (https://www.icinga.com/)
+-- Copyright (c) 2009-2017 Icinga Development Team (https://www.icinga.com/)
--
-- --------------------------------------------------------
CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_id);
CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id);
+-- #5458
+CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+
-- -----------------------------------------
-- set dbversion
-- -----------------------------------------
-SELECT updatedbversion('1.14.2');
+SELECT updatedbversion('1.14.3');
--- /dev/null
+-- -----------------------------------------
+-- upgrade path for Icinga 2.8.0
+--
+-- -----------------------------------------
+-- Copyright (c) 2017 Icinga Development Team (https://www.icinga.com)
+--
+-- Please check https://docs.icinga.com for upgrading information!
+-- -----------------------------------------
+
+-- -----------------------------------------
+-- #5458 IDO: Improve downtime removal/cancel
+-- -----------------------------------------
+
+CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time);
+
+-- -----------------------------------------
+-- set dbversion
+-- -----------------------------------------
+
+SELECT updatedbversion('1.14.3');