diff options
Diffstat (limited to '')
105 files changed, 3124 insertions, 0 deletions
diff --git a/schema/mysql-migrations/upgrade_100.sql b/schema/mysql-migrations/upgrade_100.sql new file mode 100644 index 0000000..56f8b54 --- /dev/null +++ b/schema/mysql-migrations/upgrade_100.sql @@ -0,0 +1,6 @@ +ALTER TABLE import_row_modifier + ADD COLUMN target_property VARCHAR(255) DEFAULT NULL AFTER property_name; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (100, NOW()); diff --git a/schema/mysql-migrations/upgrade_101.sql b/schema/mysql-migrations/upgrade_101.sql new file mode 100644 index 0000000..bbe1817 --- /dev/null +++ b/schema/mysql-migrations/upgrade_101.sql @@ -0,0 +1,7 @@ +ALTER TABLE icinga_host + ADD COLUMN api_key VARCHAR(40) DEFAULT NULL AFTER accept_config, + ADD UNIQUE KEY api_key (api_key); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (101, NOW()); diff --git a/schema/mysql-migrations/upgrade_102.sql b/schema/mysql-migrations/upgrade_102.sql new file mode 100644 index 0000000..5607f1e --- /dev/null +++ b/schema/mysql-migrations/upgrade_102.sql @@ -0,0 +1,13 @@ +UPDATE director_deployment_log SET startup_log = LEFT(startup_log, 20480) || ' + +[..] shortened ' +|| (LENGTH(startup_log) - 40960) +|| ' bytes by Director on schema upgrade [..] + +' || RIGHT(startup_log, 20480) WHERE LENGTH(startup_log) > 61440; + +OPTIMIZE TABLE director_deployment_log; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (102, NOW()); diff --git a/schema/mysql-migrations/upgrade_103.sql b/schema/mysql-migrations/upgrade_103.sql new file mode 100644 index 0000000..64d222b --- /dev/null +++ b/schema/mysql-migrations/upgrade_103.sql @@ -0,0 +1,12 @@ +UPDATE icinga_command_argument + SET + argument_name = '(no key)', + skip_key = 'y' + WHERE argument_name IS NULL; + +ALTER TABLE icinga_command_argument + MODIFY argument_name VARCHAR(64) COLLATE utf8_bin NOT NULL COMMENT '-x, --host'; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (103, NOW()); diff --git a/schema/mysql-migrations/upgrade_104.sql b/schema/mysql-migrations/upgrade_104.sql new file mode 100644 index 0000000..673360a --- /dev/null +++ b/schema/mysql-migrations/upgrade_104.sql @@ -0,0 +1,19 @@ +ALTER TABLE icinga_timeperiod_range + ADD COLUMN range_key VARCHAR(255) NOT NULL COMMENT 'monday, ...', + ADD COLUMN range_value VARCHAR(255) NOT NULL COMMENT '00:00-24:00, ...'; + +UPDATE icinga_timeperiod_range + SET range_key = timeperiod_key, + range_value = timeperiod_value; + +ALTER TABLE icinga_timeperiod_range + DROP PRIMARY KEY, + ADD PRIMARY KEY (timeperiod_id, range_type, range_key); + +ALTER TABLE icinga_timeperiod_range + DROP COLUMN timeperiod_key, + DROP COLUMN timeperiod_value; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (104, NOW()); diff --git a/schema/mysql-migrations/upgrade_105.sql b/schema/mysql-migrations/upgrade_105.sql new file mode 100644 index 0000000..da4efa8 --- /dev/null +++ b/schema/mysql-migrations/upgrade_105.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_service + ADD COLUMN use_var_overrides ENUM('y', 'n') DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (105, NOW()); diff --git a/schema/mysql-migrations/upgrade_107.sql b/schema/mysql-migrations/upgrade_107.sql new file mode 100644 index 0000000..fb35f07 --- /dev/null +++ b/schema/mysql-migrations/upgrade_107.sql @@ -0,0 +1,9 @@ +ALTER TABLE director_job + MODIFY last_error_message TEXT DEFAULT NULL; + +ALTER TABLE sync_rule + MODIFY last_error_message TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (107, NOW()); diff --git a/schema/mysql-migrations/upgrade_108.sql b/schema/mysql-migrations/upgrade_108.sql new file mode 100644 index 0000000..8a6ef39 --- /dev/null +++ b/schema/mysql-migrations/upgrade_108.sql @@ -0,0 +1,18 @@ +ALTER TABLE icinga_command_var + MODIFY COLUMN varname VARCHAR(255) NOT NULL COLLATE utf8_bin; + +ALTER TABLE icinga_host_var + MODIFY COLUMN varname VARCHAR(255) NOT NULL COLLATE utf8_bin; + +ALTER TABLE icinga_service_var + MODIFY COLUMN varname VARCHAR(255) NOT NULL COLLATE utf8_bin; + +ALTER TABLE icinga_user_var + MODIFY COLUMN varname VARCHAR(255) NOT NULL COLLATE utf8_bin; + +ALTER TABLE icinga_notification_var + MODIFY COLUMN varname VARCHAR(255) NOT NULL COLLATE utf8_bin; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (108, NOW()); diff --git a/schema/mysql-migrations/upgrade_109.sql b/schema/mysql-migrations/upgrade_109.sql new file mode 100644 index 0000000..1989fa7 --- /dev/null +++ b/schema/mysql-migrations/upgrade_109.sql @@ -0,0 +1,16 @@ +CREATE TABLE icinga_hostgroup_assignment ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + hostgroup_id INT(10) UNSIGNED NOT NULL, + filter_string TEXT NOT NULL, + assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign', + PRIMARY KEY (id), + CONSTRAINT icinga_hostgroup_assignment + FOREIGN KEY hostgroup (hostgroup_id) + REFERENCES icinga_hostgroup (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (109, NOW()); diff --git a/schema/mysql-migrations/upgrade_110.sql b/schema/mysql-migrations/upgrade_110.sql new file mode 100644 index 0000000..800f7ab --- /dev/null +++ b/schema/mysql-migrations/upgrade_110.sql @@ -0,0 +1,104 @@ +UPDATE icinga_host_var + SET varvalue = 'false', + format = 'json' + WHERE varvalue = 'n' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_host_var + SET varvalue = 'true', + format = 'json' + WHERE varvalue = 'y' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_service_var + SET varvalue = 'false', + format = 'json' + WHERE varvalue = 'n' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_service_var + SET varvalue = 'true', + format = 'json' + WHERE varvalue = 'y' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + + +UPDATE icinga_command_var + SET varvalue = 'false', + format = 'json' + WHERE varvalue = 'n' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_command_var + SET varvalue = 'true', + format = 'json' + WHERE varvalue = 'y' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_user_var + SET varvalue = 'false', + format = 'json' + WHERE varvalue = 'n' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_user_var + SET varvalue = 'true', + format = 'json' + WHERE varvalue = 'y' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_notification_var + SET varvalue = 'false', + format = 'json' + WHERE varvalue = 'n' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +UPDATE icinga_notification_var + SET varvalue = 'true', + format = 'json' + WHERE varvalue = 'y' + AND varname IN ( + SELECT DISTINCT varname + FROM director_datafield + WHERE datatype LIKE '%DataTypeBoolean' + ); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (110, NOW()); diff --git a/schema/mysql-migrations/upgrade_112.sql b/schema/mysql-migrations/upgrade_112.sql new file mode 100644 index 0000000..5336d35 --- /dev/null +++ b/schema/mysql-migrations/upgrade_112.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_datalist_entry + MODIFY COLUMN entry_name VARCHAR(255) COLLATE utf8_bin NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (112, NOW()); diff --git a/schema/mysql-migrations/upgrade_114.sql b/schema/mysql-migrations/upgrade_114.sql new file mode 100644 index 0000000..24d3430 --- /dev/null +++ b/schema/mysql-migrations/upgrade_114.sql @@ -0,0 +1,55 @@ +CREATE TABLE icinga_service_set ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + object_name VARCHAR(128) NOT NULL, + object_type ENUM('object', 'template', 'external_object') NOT NULL, + host_id INT(10) UNSIGNED DEFAULT NULL, + description TEXT NOT NULL, + PRIMARY KEY (id), + UNIQUE KEY object_key (object_name, host_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_service_set_service ( + service_set_id INT(10) UNSIGNED NOT NULL, + service_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (service_set_id, service_id), + CONSTRAINT service_set_set + FOREIGN KEY service_set (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT service_set_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_service_set_assignment ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + service_set_id INT(10) UNSIGNED NOT NULL, + filter_string TEXT NOT NULL, + assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign', + PRIMARY KEY (id), + CONSTRAINT icinga_service_set_assignment + FOREIGN KEY service_set (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE icinga_service_set_var ( + service_set_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + varvalue TEXT DEFAULT NULL, + format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string', + PRIMARY KEY (service_set_id, varname), + CONSTRAINT icinga_service_set_var_service + FOREIGN KEY command (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (114, NOW()); diff --git a/schema/mysql-migrations/upgrade_115.sql b/schema/mysql-migrations/upgrade_115.sql new file mode 100644 index 0000000..45f6236 --- /dev/null +++ b/schema/mysql-migrations/upgrade_115.sql @@ -0,0 +1,23 @@ +CREATE TABLE icinga_service_set_inheritance ( + service_set_id INT(10) UNSIGNED NOT NULL, + parent_service_set_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (service_set_id, parent_service_set_id), + UNIQUE KEY unique_order (service_set_id, weight), + CONSTRAINT icinga_service_set_inheritance_set + FOREIGN KEY host (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_set_inheritance_parent + FOREIGN KEY host (parent_service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE icinga_service_set MODIFY description TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (115, NOW()); diff --git a/schema/mysql-migrations/upgrade_116.sql b/schema/mysql-migrations/upgrade_116.sql new file mode 100644 index 0000000..a252d42 --- /dev/null +++ b/schema/mysql-migrations/upgrade_116.sql @@ -0,0 +1,18 @@ +ALTER TABLE sync_rule MODIFY object_type enum( + 'host', + 'service', + 'command', + 'user', + 'hostgroup', + 'servicegroup', + 'usergroup', + 'datalistEntry', + 'endpoint', + 'zone', + 'timePeriod', + 'serviceSet' +) NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (116, NOW()); diff --git a/schema/mysql-migrations/upgrade_117.sql b/schema/mysql-migrations/upgrade_117.sql new file mode 100644 index 0000000..e0ab4f3 --- /dev/null +++ b/schema/mysql-migrations/upgrade_117.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_notification_field ( + notification_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + datafield_id INT(10) UNSIGNED NOT NULL, + is_required ENUM('y', 'n') NOT NULL, + PRIMARY KEY (notification_id, datafield_id), + CONSTRAINT icinga_notification_field_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_field_datafield + FOREIGN KEY datafield(datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (117, NOW()); diff --git a/schema/mysql-migrations/upgrade_119.sql b/schema/mysql-migrations/upgrade_119.sql new file mode 100644 index 0000000..c5fcf54 --- /dev/null +++ b/schema/mysql-migrations/upgrade_119.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_service + ADD COLUMN apply_for VARCHAR(255) DEFAULT NULL AFTER use_agent; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (119, NOW()); diff --git a/schema/mysql-migrations/upgrade_120.sql b/schema/mysql-migrations/upgrade_120.sql new file mode 100644 index 0000000..4020dea --- /dev/null +++ b/schema/mysql-migrations/upgrade_120.sql @@ -0,0 +1,184 @@ +ALTER TABLE icinga_service ADD COLUMN assign_filter TEXT DEFAULT NULL; + +UPDATE icinga_service s JOIN ( + + SELECT + service_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa.filter_string + ELSE GROUP_CONCAT(sa.filter_string SEPARATOR '&') END AS filter_string + FROM ( + SELECT + sa_not.service_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_not.filter_string + ELSE '(' || GROUP_CONCAT(sa_not.filter_string SEPARATOR '&') || ')' END AS filter_string + FROM ( SELECT + sa.service_id, + '!' || sa.filter_string AS filter_string + FROM icinga_service_assignment sa + WHERE assign_type = 'ignore' + ) sa_not + GROUP BY service_id + + UNION ALL + + SELECT + sa_yes.service_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_yes.filter_string + ELSE '(' || GROUP_CONCAT(sa_yes.filter_string SEPARATOR '|') || ')' END AS filter_string + FROM ( SELECT + sa.service_id, + sa.filter_string AS filter_string + FROM icinga_service_assignment sa + WHERE assign_type = 'assign' + ) sa_yes + GROUP BY service_id + + ) sa GROUP BY service_id + +) flat_assign ON s.id = flat_assign.service_id SET s.assign_filter = flat_assign.filter_string; + +DROP TABLE icinga_service_assignment; + +ALTER TABLE icinga_service_set ADD COLUMN assign_filter TEXT DEFAULT NULL; + +UPDATE icinga_service_set s JOIN ( + + SELECT + service_set_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa.filter_string + ELSE GROUP_CONCAT(sa.filter_string SEPARATOR '&') END AS filter_string + FROM ( + SELECT + sa_not.service_set_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_not.filter_string + ELSE '(' || GROUP_CONCAT(sa_not.filter_string SEPARATOR '&') || ')' END AS filter_string + FROM ( SELECT + sa.service_set_id, + '!' || sa.filter_string AS filter_string + FROM icinga_service_set_assignment sa + WHERE assign_type = 'ignore' + ) sa_not + GROUP BY service_set_id + + UNION ALL + + SELECT + sa_yes.service_set_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_yes.filter_string + ELSE '(' || GROUP_CONCAT(sa_yes.filter_string SEPARATOR '|') || ')' END AS filter_string + FROM ( SELECT + sa.service_set_id, + sa.filter_string AS filter_string + FROM icinga_service_set_assignment sa + WHERE assign_type = 'assign' + ) sa_yes + GROUP BY service_set_id + + ) sa GROUP BY service_set_id + +) flat_assign ON s.id = flat_assign.service_set_id SET s.assign_filter = flat_assign.filter_string; + +DROP TABLE icinga_service_set_assignment; + + +ALTER TABLE icinga_notification ADD COLUMN assign_filter TEXT DEFAULT NULL; + +UPDATE icinga_notification s JOIN ( + + SELECT + notification_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa.filter_string + ELSE GROUP_CONCAT(sa.filter_string SEPARATOR '&') END AS filter_string + FROM ( + SELECT + sa_not.notification_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_not.filter_string + ELSE '(' || GROUP_CONCAT(sa_not.filter_string SEPARATOR '&') || ')' END AS filter_string + FROM ( SELECT + sa.notification_id, + '!' || sa.filter_string AS filter_string + FROM icinga_notification_assignment sa + WHERE assign_type = 'ignore' + ) sa_not + GROUP BY notification_id + + UNION ALL + + SELECT + sa_yes.notification_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_yes.filter_string + ELSE '(' || GROUP_CONCAT(sa_yes.filter_string SEPARATOR '|') || ')' END AS filter_string + FROM ( SELECT + sa.notification_id, + sa.filter_string AS filter_string + FROM icinga_notification_assignment sa + WHERE assign_type = 'assign' + ) sa_yes + GROUP BY notification_id + + ) sa GROUP BY notification_id + +) flat_assign ON s.id = flat_assign.notification_id SET s.assign_filter = flat_assign.filter_string; + +DROP TABLE icinga_notification_assignment; + +ALTER TABLE icinga_hostgroup ADD COLUMN assign_filter TEXT DEFAULT NULL; + +UPDATE icinga_hostgroup s JOIN ( + + SELECT + hostgroup_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa.filter_string + ELSE GROUP_CONCAT(sa.filter_string SEPARATOR '&') END AS filter_string + FROM ( + SELECT + sa_not.hostgroup_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_not.filter_string + ELSE '(' || GROUP_CONCAT(sa_not.filter_string SEPARATOR '&') || ')' END AS filter_string + FROM ( SELECT + sa.hostgroup_id, + '!' || sa.filter_string AS filter_string + FROM icinga_hostgroup_assignment sa + WHERE assign_type = 'ignore' + ) sa_not + GROUP BY hostgroup_id + + UNION ALL + + SELECT + sa_yes.hostgroup_id, + CASE WHEN COUNT(*) = 0 THEN NULL + WHEN COUNT(*) = 1 THEN sa_yes.filter_string + ELSE '(' || GROUP_CONCAT(sa_yes.filter_string SEPARATOR '|') || ')' END AS filter_string + FROM ( SELECT + sa.hostgroup_id, + sa.filter_string AS filter_string + FROM icinga_hostgroup_assignment sa + WHERE assign_type = 'assign' + ) sa_yes + GROUP BY hostgroup_id + + ) sa GROUP BY hostgroup_id + +) flat_assign ON s.id = flat_assign.hostgroup_id SET s.assign_filter = flat_assign.filter_string; + +DROP TABLE icinga_hostgroup_assignment; + + +ALTER TABLE icinga_servicegroup ADD COLUMN assign_filter TEXT DEFAULT NULL; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (120, NOW()); diff --git a/schema/mysql-migrations/upgrade_121.sql b/schema/mysql-migrations/upgrade_121.sql new file mode 100644 index 0000000..24c307a --- /dev/null +++ b/schema/mysql-migrations/upgrade_121.sql @@ -0,0 +1,8 @@ +ALTER TABLE icinga_service + ADD COLUMN service_set_id INT(10) UNSIGNED DEFAULT NULL AFTER host_id; + +DROP TABLE icinga_service_set_service; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (121, NOW()); diff --git a/schema/mysql-migrations/upgrade_122.sql b/schema/mysql-migrations/upgrade_122.sql new file mode 100644 index 0000000..6a94e05 --- /dev/null +++ b/schema/mysql-migrations/upgrade_122.sql @@ -0,0 +1,12 @@ +ALTER TABLE director_generated_file + ADD COLUMN cnt_apply INT(10) UNSIGNED NOT NULL DEFAULT 0; + +UPDATE director_generated_file +SET cnt_apply = ROUND( + (LENGTH(content) - LENGTH( REPLACE(content, 'apply ', '') ) ) + / LENGTH('apply ') +); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (122, NOW()); diff --git a/schema/mysql-migrations/upgrade_123.sql b/schema/mysql-migrations/upgrade_123.sql new file mode 100644 index 0000000..024ed72 --- /dev/null +++ b/schema/mysql-migrations/upgrade_123.sql @@ -0,0 +1,30 @@ +-- cleanup dangling service_set before we add foreign key +DELETE ss FROM icinga_service_set AS ss + LEFT JOIN icinga_host AS h ON h.id = ss.host_id + WHERE ss.object_type = 'object' + AND ss.host_id IS NOT NULL + AND h.id IS NULL; + +-- cleanup dangling services to service_set +DELETE s FROM icinga_service AS s + LEFT JOIN icinga_service_set AS ss ON ss.id = s.service_set_id + WHERE s.object_type IN ('object', 'apply') + AND s.service_set_id IS NOT NULL + AND ss.id IS NULL; + + +ALTER TABLE icinga_service_set + ADD FOREIGN KEY icinga_service_set_host (host_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + ADD FOREIGN KEY icinga_service_service_set (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (123, NOW()); diff --git a/schema/mysql-migrations/upgrade_124.sql b/schema/mysql-migrations/upgrade_124.sql new file mode 100644 index 0000000..c7e218f --- /dev/null +++ b/schema/mysql-migrations/upgrade_124.sql @@ -0,0 +1,3 @@ +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (124, NOW()); diff --git a/schema/mysql-migrations/upgrade_125.sql b/schema/mysql-migrations/upgrade_125.sql new file mode 100644 index 0000000..b1ffea1 --- /dev/null +++ b/schema/mysql-migrations/upgrade_125.sql @@ -0,0 +1,18 @@ +ALTER TABLE icinga_command_field + ADD COLUMN var_filter TEXT DEFAULT NULL; + +ALTER TABLE icinga_host_field + ADD COLUMN var_filter TEXT DEFAULT NULL; + +ALTER TABLE icinga_notification_field + ADD COLUMN var_filter TEXT DEFAULT NULL; + +ALTER TABLE icinga_service_field + ADD COLUMN var_filter TEXT DEFAULT NULL; + +ALTER TABLE icinga_user_field + ADD COLUMN var_filter TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (125, NOW()); diff --git a/schema/mysql-migrations/upgrade_126.sql b/schema/mysql-migrations/upgrade_126.sql new file mode 100644 index 0000000..d655eaa --- /dev/null +++ b/schema/mysql-migrations/upgrade_126.sql @@ -0,0 +1,217 @@ +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service_set' + AND constraint_name = 'icinga_service_set_host' + )), + 'ALTER TABLE icinga_service_set DROP FOREIGN KEY icinga_service_set_host', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service_set' + AND constraint_name = 'icinga_service_set_ibfk_1' + )), + 'ALTER TABLE icinga_service_set DROP FOREIGN KEY icinga_service_set_ibfk_1', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service_set' + AND constraint_name = 'icinga_service_set_ibfk_2' + )), + 'ALTER TABLE icinga_service_set DROP FOREIGN KEY icinga_service_set_ibfk_2', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service_set' + AND constraint_name = 'icinga_service_set_ibfk_3' + )), + 'ALTER TABLE icinga_service_set DROP FOREIGN KEY icinga_service_set_ibfk_3', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service' + AND constraint_name = 'icinga_service_service_set' + )), + 'ALTER TABLE icinga_service DROP FOREIGN KEY icinga_service_service_set', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT * FROM information_schema.table_constraints + WHERE + table_schema = DATABASE() + AND table_name = 'icinga_service' + AND constraint_name = 'icinga_service_ibfk_1' + )), + 'ALTER TABLE icinga_service DROP FOREIGN KEY icinga_service_ibfk_1', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = 'icinga_service' + AND index_name = 'icinga_service_service_set' + )), + 'ALTER TABLE icinga_service DROP INDEX icinga_service_service_set', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = 'icinga_service_set' + AND index_name = 'icinga_service_set_ibfk_1' + )), + 'ALTER TABLE icinga_service_set DROP INDEX icinga_service_set_ibfk_1', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = 'icinga_service_set' + AND index_name = 'icinga_service_set_host' + )), + 'ALTER TABLE icinga_service_set DROP INDEX icinga_service_set_host', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = 'icinga_service' + AND index_name = 'icinga_service_ibfk_1' + )), + 'ALTER TABLE icinga_service_set DROP INDEX icinga_service_ibfk_1', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +SET @stmt = (SELECT IF( + (SELECT EXISTS( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = 'icinga_service_set' + AND index_name = 'icinga_service_set_ibfk_2' + )), + 'ALTER TABLE icinga_service_set DROP INDEX icinga_service_set_ibfk_2', + 'SELECT 1' +)); + +PREPARE stmt FROM @stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SET @stmt = NULL; + + +ALTER TABLE icinga_service_set + ADD CONSTRAINT icinga_service_set_host + FOREIGN KEY host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + ADD CONSTRAINT icinga_service_service_set + FOREIGN KEY service_set (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (126, NOW()); diff --git a/schema/mysql-migrations/upgrade_127.sql b/schema/mysql-migrations/upgrade_127.sql new file mode 100644 index 0000000..575675e --- /dev/null +++ b/schema/mysql-migrations/upgrade_127.sql @@ -0,0 +1,152 @@ +ALTER TABLE icinga_command_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER command_id, + ADD INDEX search_idx (varname), + ADD INDEX checksum (checksum); + +ALTER TABLE icinga_host_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER host_id, + ADD INDEX checksum (checksum); + +ALTER TABLE icinga_notification_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER notification_id, + ADD INDEX checksum (checksum); + +ALTER TABLE icinga_service_set_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER service_set_id, + ADD INDEX search_idx (varname), + ADD INDEX checksum (checksum); + +ALTER TABLE icinga_service_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER service_id, + ADD INDEX checksum (checksum); + +ALTER TABLE icinga_user_var + ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER user_id, + ADD INDEX checksum (checksum); + +CREATE TABLE icinga_var ( + checksum VARBINARY(20) NOT NULL, + rendered_checksum VARBINARY(20) NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + varvalue TEXT NOT NULL, + rendered TEXT NOT NULL, + PRIMARY KEY (checksum), + INDEX search_idx (varname) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_flat_var ( + var_checksum VARBINARY(20) NOT NULL, + flatname_checksum VARBINARY(20) NOT NULL, + flatname VARCHAR(512) NOT NULL COLLATE utf8_bin, + flatvalue TEXT NOT NULL, + PRIMARY KEY (var_checksum, flatname_checksum), + INDEX search_varname (flatname (191)), + INDEX search_varvalue (flatvalue (128)), + CONSTRAINT flat_var_var + FOREIGN KEY checksum (var_checksum) + REFERENCES icinga_var (checksum) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_command_resolved_var ( + command_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (command_id, checksum), + INDEX search_varname (varname), + CONSTRAINT command_resolved_var_command + FOREIGN KEY command (command_id) + REFERENCES icinga_command (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT command_resolved_var_checksum + FOREIGN KEY checksum (checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_host_resolved_var ( + host_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (host_id, checksum), + INDEX search_varname (varname), + FOREIGN KEY host_resolved_var_host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + FOREIGN KEY host_resolved_var_checksum (checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_notification_resolved_var ( + notification_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (notification_id, checksum), + INDEX search_varname (varname), + FOREIGN KEY notification_resolved_var_notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + FOREIGN KEY notification_resolved_var_checksum (checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_service_set_resolved_var ( + service_set_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (service_set_id, checksum), + INDEX search_varname (varname), + FOREIGN KEY service_set_resolved_var_service_set (service_set_id) + REFERENCES icinga_service_set (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + FOREIGN KEY service_set_resolved_var_checksum(checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_service_resolved_var ( + service_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (service_id, checksum), + INDEX search_varname (varname), + FOREIGN KEY service_resolve_var_service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + FOREIGN KEY service_resolve_var_checksum(checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_user_resolved_var ( + user_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) NOT NULL COLLATE utf8_bin, + checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (user_id, checksum), + INDEX search_varname (varname), + FOREIGN KEY user_resolve_var_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + FOREIGN KEY user_resolve_var_checksum(checksum) + REFERENCES icinga_var (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (127, NOW()); diff --git a/schema/mysql-migrations/upgrade_128.sql b/schema/mysql-migrations/upgrade_128.sql new file mode 100644 index 0000000..30e809c --- /dev/null +++ b/schema/mysql-migrations/upgrade_128.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_activity_log + ADD INDEX search_author (author); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (128, NOW()); diff --git a/schema/mysql-migrations/upgrade_129.sql b/schema/mysql-migrations/upgrade_129.sql new file mode 100644 index 0000000..b47601c --- /dev/null +++ b/schema/mysql-migrations/upgrade_129.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_datafield + MODIFY COLUMN varname VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (129, NOW()); diff --git a/schema/mysql-migrations/upgrade_130.sql b/schema/mysql-migrations/upgrade_130.sql new file mode 100644 index 0000000..c862d0d --- /dev/null +++ b/schema/mysql-migrations/upgrade_130.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_hostgroup + MODIFY object_type enum('object', 'template', 'external_object') NOT NULL; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (130, NOW()); diff --git a/schema/mysql-migrations/upgrade_131.sql b/schema/mysql-migrations/upgrade_131.sql new file mode 100644 index 0000000..282e060 --- /dev/null +++ b/schema/mysql-migrations/upgrade_131.sql @@ -0,0 +1,19 @@ +CREATE TABLE icinga_hostgroup_host_resolved ( + hostgroup_id INT(10) UNSIGNED NOT NULL, + host_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (hostgroup_id, host_id), + CONSTRAINT icinga_hostgroup_host_resolved_host + FOREIGN KEY host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_hostgroup_host_resolved_hostgroup + FOREIGN KEY hostgroup (hostgroup_id) + REFERENCES icinga_hostgroup (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (131, NOW()); diff --git a/schema/mysql-migrations/upgrade_132.sql b/schema/mysql-migrations/upgrade_132.sql new file mode 100644 index 0000000..76be96f --- /dev/null +++ b/schema/mysql-migrations/upgrade_132.sql @@ -0,0 +1,21 @@ +CREATE TABLE icinga_host_template_choice ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + object_name VARCHAR(64) NOT NULL, + description TEXT DEFAULT NULL, + min_required SMALLINT UNSIGNED NOT NULL DEFAULT 0, + max_allowed SMALLINT UNSIGNED NOT NULL DEFAULT 1, + PRIMARY KEY (id), + UNIQUE KEY (object_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE icinga_host + ADD COLUMN template_choice_id INT(10) UNSIGNED DEFAULT NULL, + ADD CONSTRAINT icinga_host_template_choice + FOREIGN KEY choice (template_choice_id) + REFERENCES icinga_host_template_choice (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (132, NOW()); diff --git a/schema/mysql-migrations/upgrade_133.sql b/schema/mysql-migrations/upgrade_133.sql new file mode 100644 index 0000000..9f1a474 --- /dev/null +++ b/schema/mysql-migrations/upgrade_133.sql @@ -0,0 +1,21 @@ +CREATE TABLE icinga_service_template_choice ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + object_name VARCHAR(64) NOT NULL, + description TEXT DEFAULT NULL, + min_required SMALLINT UNSIGNED NOT NULL DEFAULT 0, + max_allowed SMALLINT UNSIGNED NOT NULL DEFAULT 1, + PRIMARY KEY (id), + UNIQUE KEY (object_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE icinga_service + ADD COLUMN template_choice_id INT(10) UNSIGNED DEFAULT NULL, + ADD CONSTRAINT icinga_service_template_choice + FOREIGN KEY choice (template_choice_id) + REFERENCES icinga_service_template_choice (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (133, NOW()); diff --git a/schema/mysql-migrations/upgrade_134.sql b/schema/mysql-migrations/upgrade_134.sql new file mode 100644 index 0000000..b652e5b --- /dev/null +++ b/schema/mysql-migrations/upgrade_134.sql @@ -0,0 +1,19 @@ +ALTER TABLE icinga_host + DROP FOREIGN KEY icinga_host_template_choice, + ADD CONSTRAINT icinga_host_template_choice_v2 + FOREIGN KEY template_choice (template_choice_id) + REFERENCES icinga_host_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +ALTER TABLE icinga_service + DROP FOREIGN KEY icinga_service_template_choice, + ADD CONSTRAINT icinga_service_template_choice_v2 + FOREIGN KEY template_choice (template_choice_id) + REFERENCES icinga_service_template_choice (id) + ON DELETE SET NULL + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (134, NOW()); diff --git a/schema/mysql-migrations/upgrade_135.sql b/schema/mysql-migrations/upgrade_135.sql new file mode 100644 index 0000000..6a1d687 --- /dev/null +++ b/schema/mysql-migrations/upgrade_135.sql @@ -0,0 +1,9 @@ +ALTER TABLE icinga_host + ADD COLUMN check_timeout SMALLINT UNSIGNED DEFAULT NULL AFTER retry_interval; + +ALTER TABLE icinga_service + ADD COLUMN check_timeout SMALLINT UNSIGNED DEFAULT NULL AFTER retry_interval; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (135, NOW()); diff --git a/schema/mysql-migrations/upgrade_136.sql b/schema/mysql-migrations/upgrade_136.sql new file mode 100644 index 0000000..d308062 --- /dev/null +++ b/schema/mysql-migrations/upgrade_136.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_datalist_entry + ADD COLUMN allowed_roles VARCHAR(255) DEFAULT NULL; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (136, NOW()); diff --git a/schema/mysql-migrations/upgrade_137.sql b/schema/mysql-migrations/upgrade_137.sql new file mode 100644 index 0000000..535d2bc --- /dev/null +++ b/schema/mysql-migrations/upgrade_137.sql @@ -0,0 +1,9 @@ +ALTER TABLE import_source + ADD COLUMN description TEXT DEFAULT NULL; + +ALTER TABLE sync_rule + ADD COLUMN description TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (137, NOW()); diff --git a/schema/mysql-migrations/upgrade_138.sql b/schema/mysql-migrations/upgrade_138.sql new file mode 100644 index 0000000..8561c00 --- /dev/null +++ b/schema/mysql-migrations/upgrade_138.sql @@ -0,0 +1,6 @@ +ALTER TABLE import_row_modifier + ADD COLUMN description TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (138, NOW()); diff --git a/schema/mysql-migrations/upgrade_139.sql b/schema/mysql-migrations/upgrade_139.sql new file mode 100644 index 0000000..817244b --- /dev/null +++ b/schema/mysql-migrations/upgrade_139.sql @@ -0,0 +1,7 @@ +UPDATE import_row_modifier SET priority = id; + +ALTER TABLE import_row_modifier ADD UNIQUE INDEX idx_prio (source_id, priority); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (139, NOW()); diff --git a/schema/mysql-migrations/upgrade_140.sql b/schema/mysql-migrations/upgrade_140.sql new file mode 100644 index 0000000..996e9ef --- /dev/null +++ b/schema/mysql-migrations/upgrade_140.sql @@ -0,0 +1,5 @@ +UPDATE sync_property SET priority = 10000 - priority; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (140, NOW()); diff --git a/schema/mysql-migrations/upgrade_141.sql b/schema/mysql-migrations/upgrade_141.sql new file mode 100644 index 0000000..a382208 --- /dev/null +++ b/schema/mysql-migrations/upgrade_141.sql @@ -0,0 +1,7 @@ +UPDATE icinga_service_set + SET object_type = 'template' + WHERE object_type = 'object' AND host_id IS NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (141, NOW()); diff --git a/schema/mysql-migrations/upgrade_143.sql b/schema/mysql-migrations/upgrade_143.sql new file mode 100644 index 0000000..7d07385 --- /dev/null +++ b/schema/mysql-migrations/upgrade_143.sql @@ -0,0 +1,21 @@ +ALTER TABLE icinga_host_template_choice + ADD COLUMN required_template_id INT(10) UNSIGNED DEFAULT NULL, + ADD COLUMN allowed_roles VARCHAR(255) DEFAULT NULL, + ADD CONSTRAINT host_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE icinga_service_template_choice + ADD COLUMN required_template_id INT(10) UNSIGNED DEFAULT NULL, + ADD COLUMN allowed_roles VARCHAR(255) DEFAULT NULL, + ADD CONSTRAINT service_template_choice_required_template + FOREIGN KEY required_template (required_template_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (143, NOW()); diff --git a/schema/mysql-migrations/upgrade_144.sql b/schema/mysql-migrations/upgrade_144.sql new file mode 100644 index 0000000..fff6f8f --- /dev/null +++ b/schema/mysql-migrations/upgrade_144.sql @@ -0,0 +1,91 @@ +CREATE TABLE icinga_dependency ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') NOT NULL, + disabled ENUM('y', 'n') NOT NULL DEFAULT 'n', + apply_to ENUM('host', 'service') DEFAULT NULL, + parent_host_id INT(10) UNSIGNED DEFAULT NULL, + parent_service_id INT(10) UNSIGNED DEFAULT NULL, + child_host_id INT(10) UNSIGNED DEFAULT NULL, + child_service_id INT(10) UNSIGNED DEFAULT NULL, + disable_checks ENUM('y', 'n') DEFAULT NULL, + disable_notifications ENUM('y', 'n') DEFAULT NULL, + ignore_soft_states ENUM('y', 'n') DEFAULT NULL, + period_id INT(10) UNSIGNED DEFAULT NULL, + zone_id INT(10) UNSIGNED DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + parent_service_by_name VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (id), + CONSTRAINT icinga_dependency_parent_host + FOREIGN KEY parent_host (parent_host_id) + REFERENCES icinga_host (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_parent_service + FOREIGN KEY parent_service (parent_service_id) + REFERENCES icinga_service (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_child_host + FOREIGN KEY child_host (child_host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_child_service + FOREIGN KEY child_service (child_service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_period + FOREIGN KEY period (period_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_dependency_inheritance ( + dependency_id INT(10) UNSIGNED NOT NULL, + parent_dependency_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (dependency_id, parent_dependency_id), + UNIQUE KEY unique_order (dependency_id, weight), + CONSTRAINT icinga_dependency_inheritance_dependency + FOREIGN KEY dependency (dependency_id) + REFERENCES icinga_dependency (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_dependency_inheritance_parent_dependency + FOREIGN KEY parent_dependency (parent_dependency_id) + REFERENCES icinga_dependency (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_dependency_states_set ( + dependency_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'OK', + 'Warning', + 'Critical', + 'Unknown', + 'Up', + 'Down' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (dependency_id, property, merge_behaviour), + CONSTRAINT icinga_dependency_states_set_dependency + FOREIGN KEY icinga_dependency (dependency_id) + REFERENCES icinga_dependency (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (144, NOW()); diff --git a/schema/mysql-migrations/upgrade_145.sql b/schema/mysql-migrations/upgrade_145.sql new file mode 100644 index 0000000..a0e1853 --- /dev/null +++ b/schema/mysql-migrations/upgrade_145.sql @@ -0,0 +1,7 @@ +ALTER TABLE import_row_modifier + ADD INDEX source_id (source_id), + DROP INDEX idx_prio; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (145, NOW()); diff --git a/schema/mysql-migrations/upgrade_146.sql b/schema/mysql-migrations/upgrade_146.sql new file mode 100644 index 0000000..0520219 --- /dev/null +++ b/schema/mysql-migrations/upgrade_146.sql @@ -0,0 +1,14 @@ +ALTER TABLE icinga_host + DROP COLUMN flapping_threshold, + ADD COLUMN flapping_threshold_high SMALLINT UNSIGNED DEFAULT NULL, + ADD COLUMN flapping_threshold_low SMALLINT UNSIGNED DEFAULT NULL; + +ALTER TABLE icinga_service + DROP COLUMN flapping_threshold, + ADD COLUMN flapping_threshold_high SMALLINT UNSIGNED DEFAULT NULL, + ADD COLUMN flapping_threshold_low SMALLINT UNSIGNED DEFAULT NULL; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (146, NOW()); diff --git a/schema/mysql-migrations/upgrade_147.sql b/schema/mysql-migrations/upgrade_147.sql new file mode 100644 index 0000000..d609cda --- /dev/null +++ b/schema/mysql-migrations/upgrade_147.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_host_service_blacklist ( + host_id INT(10) UNSIGNED NOT NULL, + service_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (host_id, service_id), + CONSTRAINT icinga_host_service_bl_host + FOREIGN KEY host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_host_service_bl_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (147, NOW()); diff --git a/schema/mysql-migrations/upgrade_148.sql b/schema/mysql-migrations/upgrade_148.sql new file mode 100644 index 0000000..2d15c82 --- /dev/null +++ b/schema/mysql-migrations/upgrade_148.sql @@ -0,0 +1,10 @@ +ALTER TABLE import_source + MODIFY provider_class VARCHAR(128) NOT NULL; + +ALTER TABLE import_row_modifier + MODIFY provider_class VARCHAR(128) NOT NULL; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (148, NOW()); diff --git a/schema/mysql-migrations/upgrade_149.sql b/schema/mysql-migrations/upgrade_149.sql new file mode 100644 index 0000000..5940311 --- /dev/null +++ b/schema/mysql-migrations/upgrade_149.sql @@ -0,0 +1,11 @@ +ALTER TABLE icinga_usergroup + ADD COLUMN zone_id INT(10) UNSIGNED DEFAULT NULL, + ADD CONSTRAINT icinga_usergroup_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (149, NOW()); diff --git a/schema/mysql-migrations/upgrade_150.sql b/schema/mysql-migrations/upgrade_150.sql new file mode 100644 index 0000000..92a7a6d --- /dev/null +++ b/schema/mysql-migrations/upgrade_150.sql @@ -0,0 +1,17 @@ +UPDATE icinga_user u +SET period_id = NULL +WHERE NOT EXISTS ( + SELECT id FROM icinga_timeperiod + WHERE id = u.period_id +) AND u.period_id IS NOT NULL; + +ALTER TABLE icinga_user + ADD CONSTRAINT icinga_user_period + FOREIGN KEY period (period_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (150, NOW()); diff --git a/schema/mysql-migrations/upgrade_151.sql b/schema/mysql-migrations/upgrade_151.sql new file mode 100644 index 0000000..a811fd4 --- /dev/null +++ b/schema/mysql-migrations/upgrade_151.sql @@ -0,0 +1,38 @@ +ALTER TABLE icinga_timeperiod + ADD COLUMN prefer_includes ENUM('y', 'n') DEFAULT NULL; + +CREATE TABLE icinga_timeperiod_include ( + timeperiod_id INT(10) UNSIGNED NOT NULL, + include_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (timeperiod_id, include_id), + CONSTRAINT icinga_timeperiod_include + FOREIGN KEY timeperiod (include_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + CONSTRAINT icinga_timeperiod_include_timeperiod + FOREIGN KEY include (timeperiod_id) + REFERENCES icinga_timeperiod (id) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +CREATE TABLE icinga_timeperiod_exclude ( + timeperiod_id INT(10) UNSIGNED NOT NULL, + exclude_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (timeperiod_id, exclude_id), + CONSTRAINT icinga_timeperiod_exclude + FOREIGN KEY timeperiod (exclude_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + CONSTRAINT icinga_timeperiod_exclude_timeperiod + FOREIGN KEY exclude (timeperiod_id) + REFERENCES icinga_timeperiod (id) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (151, NOW()); diff --git a/schema/mysql-migrations/upgrade_152.sql b/schema/mysql-migrations/upgrade_152.sql new file mode 100644 index 0000000..91e8eea --- /dev/null +++ b/schema/mysql-migrations/upgrade_152.sql @@ -0,0 +1,9 @@ +ALTER TABLE import_source + ADD UNIQUE INDEX source_name (source_name); + +ALTER TABLE sync_rule + ADD UNIQUE INDEX rule_name (rule_name); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (152, NOW()); diff --git a/schema/mysql-migrations/upgrade_153.sql b/schema/mysql-migrations/upgrade_153.sql new file mode 100644 index 0000000..fa85130 --- /dev/null +++ b/schema/mysql-migrations/upgrade_153.sql @@ -0,0 +1,42 @@ +CREATE TABLE director_basket ( + uuid VARBINARY(16) NOT NULL, + basket_name VARCHAR(64) NOT NULL, + owner_type ENUM( + 'user', + 'usergroup', + 'role' + ) NOT NULL, + owner_value VARCHAR(255) NOT NULL, + objects MEDIUMTEXT NOT NULL, -- json-encoded + PRIMARY KEY (uuid), + UNIQUE INDEX basket_name (basket_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin; + +CREATE TABLE director_basket_content ( + checksum VARBINARY(20) NOT NULL, + summary VARCHAR(255) NOT NULL, -- json + content MEDIUMTEXT NOT NULL, -- json + PRIMARY KEY (checksum) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin; + +CREATE TABLE director_basket_snapshot ( + basket_uuid VARBINARY(16) NOT NULL, + ts_create BIGINT(20) NOT NULL, + content_checksum VARBINARY(20) NOT NULL, + PRIMARY KEY (basket_uuid, ts_create), + INDEX sort_idx (ts_create), + CONSTRAINT basked_snapshot_basket + FOREIGN KEY director_basket_snapshot (basket_uuid) + REFERENCES director_basket (uuid) + ON DELETE CASCADE + ON UPDATE RESTRICT, + CONSTRAINT basked_snapshot_content + FOREIGN KEY content_checksum (content_checksum) + REFERENCES director_basket_content (checksum) + ON DELETE RESTRICT + ON UPDATE RESTRICT +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (153, NOW()); diff --git a/schema/mysql-migrations/upgrade_154.sql b/schema/mysql-migrations/upgrade_154.sql new file mode 100644 index 0000000..08274b0 --- /dev/null +++ b/schema/mysql-migrations/upgrade_154.sql @@ -0,0 +1,12 @@ + +UPDATE icinga_command_argument +SET argument_format = NULL +WHERE argument_value IS NULL; + +UPDATE icinga_command_argument +SET set_if_format = NULL +WHERE set_if IS NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (154, NOW()); diff --git a/schema/mysql-migrations/upgrade_155.sql b/schema/mysql-migrations/upgrade_155.sql new file mode 100644 index 0000000..eab331f --- /dev/null +++ b/schema/mysql-migrations/upgrade_155.sql @@ -0,0 +1,19 @@ +CREATE TABLE icinga_servicegroup_service_resolved ( + servicegroup_id INT(10) UNSIGNED NOT NULL, + service_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (servicegroup_id, service_id), + CONSTRAINT icinga_servicegroup_service_resolved_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_servicegroup_service_resolved_servicegroup + FOREIGN KEY servicegroup (servicegroup_id) + REFERENCES icinga_servicegroup (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (155, NOW()); diff --git a/schema/mysql-migrations/upgrade_156.sql b/schema/mysql-migrations/upgrade_156.sql new file mode 100644 index 0000000..cd13edf --- /dev/null +++ b/schema/mysql-migrations/upgrade_156.sql @@ -0,0 +1,7 @@ +ALTER TABLE icinga_command + DROP INDEX object_name, +ADD UNIQUE INDEX object_name (object_name); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (156, NOW()); diff --git a/schema/mysql-migrations/upgrade_157.sql b/schema/mysql-migrations/upgrade_157.sql new file mode 100644 index 0000000..f093a88 --- /dev/null +++ b/schema/mysql-migrations/upgrade_157.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_basket_content + MODIFY COLUMN summary VARCHAR(500) NOT NULL; + + INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (157, NOW()); diff --git a/schema/mysql-migrations/upgrade_159.sql b/schema/mysql-migrations/upgrade_159.sql new file mode 100644 index 0000000..4de3cc6 --- /dev/null +++ b/schema/mysql-migrations/upgrade_159.sql @@ -0,0 +1,6 @@ +ALTER TABLE director_generated_file + MODIFY COLUMN content LONGTEXT NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (159, NOW()); diff --git a/schema/mysql-migrations/upgrade_160.sql b/schema/mysql-migrations/upgrade_160.sql new file mode 100644 index 0000000..3afbf47 --- /dev/null +++ b/schema/mysql-migrations/upgrade_160.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_command + ADD COLUMN is_string enum ('y', 'n') NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (160, NOW()); diff --git a/schema/mysql-migrations/upgrade_161.sql b/schema/mysql-migrations/upgrade_161.sql new file mode 100644 index 0000000..f8134a4 --- /dev/null +++ b/schema/mysql-migrations/upgrade_161.sql @@ -0,0 +1,58 @@ +CREATE TABLE icinga_scheduled_downtime ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + object_name VARCHAR(255) NOT NULL, + zone_id INT(10) UNSIGNED DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') NOT NULL, + disabled ENUM('y', 'n') NOT NULL DEFAULT 'n', + apply_to ENUM('host', 'service') DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + author VARCHAR(255) DEFAULT NULL, + comment TEXT DEFAULT NULL, + fixed ENUM('y', 'n') DEFAULT NULL, + duration INT(10) UNSIGNED DEFAULT NULL, + PRIMARY KEY (id), + UNIQUE INDEX object_name (object_name), + CONSTRAINT icinga_scheduled_downtime_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_scheduled_downtime_inheritance ( + scheduled_downtime_id INT(10) UNSIGNED NOT NULL, + parent_scheduled_downtime_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (scheduled_downtime_id, parent_scheduled_downtime_id), + UNIQUE KEY unique_order (scheduled_downtime_id, weight), + CONSTRAINT icinga_scheduled_downtime_inheritance_downtime + FOREIGN KEY host (scheduled_downtime_id) + REFERENCES icinga_scheduled_downtime (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_scheduled_downtime_inheritance_parent_downtime + FOREIGN KEY host (parent_scheduled_downtime_id) + REFERENCES icinga_scheduled_downtime (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_scheduled_downtime_range ( + scheduled_downtime_id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + range_key VARCHAR(255) NOT NULL COMMENT 'monday, ...', + range_value VARCHAR(255) NOT NULL COMMENT '00:00-24:00, ...', + range_type ENUM('include', 'exclude') NOT NULL DEFAULT 'include' + COMMENT 'include -> ranges {}, exclude ranges_ignore {} - not yet', + merge_behaviour ENUM('set', 'add', 'substract') NOT NULL DEFAULT 'set' + COMMENT 'set -> = {}, add -> += {}, substract -> -= {}', + PRIMARY KEY (scheduled_downtime_id, range_type, range_key), + CONSTRAINT icinga_scheduled_downtime_range_downtime + FOREIGN KEY scheduled_downtime (scheduled_downtime_id) + REFERENCES icinga_scheduled_downtime (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (161, NOW()); diff --git a/schema/mysql-migrations/upgrade_162.sql b/schema/mysql-migrations/upgrade_162.sql new file mode 100644 index 0000000..7af104a --- /dev/null +++ b/schema/mysql-migrations/upgrade_162.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_scheduled_downtime + ADD COLUMN with_services ENUM('y', 'n') NULL DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (162, NOW()); diff --git a/schema/mysql-migrations/upgrade_163.sql b/schema/mysql-migrations/upgrade_163.sql new file mode 100644 index 0000000..610c0f6 --- /dev/null +++ b/schema/mysql-migrations/upgrade_163.sql @@ -0,0 +1,38 @@ +-- when applying manually make sure to set a sensible timezone for your users +-- otherwise the server / client timezone will be used! + +-- SET time_zone = '+02:00'; + +SET sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO'; + +ALTER TABLE director_activity_log + MODIFY change_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; + +ALTER TABLE director_deployment_log + MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + MODIFY end_time TIMESTAMP NULL DEFAULT NULL, + MODIFY abort_time TIMESTAMP NULL DEFAULT NULL; + +ALTER TABLE director_schema_migration + MODIFY migration_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; + +ALTER TABLE director_job + MODIFY ts_last_attempt TIMESTAMP NULL DEFAULT NULL, + MODIFY ts_last_error TIMESTAMP NULL DEFAULT NULL; + +ALTER TABLE import_source + MODIFY last_attempt TIMESTAMP NULL DEFAULT NULL; + +ALTER TABLE import_run + MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + MODIFY end_time TIMESTAMP NULL DEFAULT NULL; + +ALTER TABLE sync_rule + MODIFY last_attempt TIMESTAMP NULL DEFAULT NULL; + +ALTER TABLE sync_run + MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (163, NOW()); diff --git a/schema/mysql-migrations/upgrade_164.sql b/schema/mysql-migrations/upgrade_164.sql new file mode 100644 index 0000000..19dec3d --- /dev/null +++ b/schema/mysql-migrations/upgrade_164.sql @@ -0,0 +1,8 @@ +SET sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO'; + +ALTER TABLE icinga_dependency + ADD COLUMN parent_host_var VARCHAR(128) DEFAULT NULL AFTER parent_host_id; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (164, NOW()); diff --git a/schema/mysql-migrations/upgrade_165.sql b/schema/mysql-migrations/upgrade_165.sql new file mode 100644 index 0000000..dec47ce --- /dev/null +++ b/schema/mysql-migrations/upgrade_165.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_host + MODIFY COLUMN address VARCHAR(255) DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (165, NOW()); diff --git a/schema/mysql-migrations/upgrade_166.sql b/schema/mysql-migrations/upgrade_166.sql new file mode 100644 index 0000000..92b56f3 --- /dev/null +++ b/schema/mysql-migrations/upgrade_166.sql @@ -0,0 +1,21 @@ +ALTER TABLE sync_rule MODIFY object_type enum( + 'host', + 'service', + 'command', + 'user', + 'hostgroup', + 'servicegroup', + 'usergroup', + 'datalistEntry', + 'endpoint', + 'zone', + 'timePeriod', + 'serviceSet', + 'scheduledDowntime', + 'notification', + 'dependency' +) NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (166, NOW()); diff --git a/schema/mysql-migrations/upgrade_167.sql b/schema/mysql-migrations/upgrade_167.sql new file mode 100644 index 0000000..7a33bec --- /dev/null +++ b/schema/mysql-migrations/upgrade_167.sql @@ -0,0 +1,25 @@ +CREATE TABLE director_daemon_info ( + instance_uuid_hex VARCHAR(32) NOT NULL, -- random by daemon + schema_version SMALLINT UNSIGNED NOT NULL, + fqdn VARCHAR(255) NOT NULL, + username VARCHAR(64) NOT NULL, + pid INT UNSIGNED NOT NULL, + binary_path VARCHAR(128) NOT NULL, + binary_realpath VARCHAR(128) NOT NULL, + php_binary_path VARCHAR(128) NOT NULL, + php_binary_realpath VARCHAR(128) NOT NULL, + php_version VARCHAR(64) NOT NULL, + php_integer_size SMALLINT NOT NULL, + running_with_systemd ENUM('y', 'n') NOT NULL, + ts_started BIGINT(20) NOT NULL, + ts_stopped BIGINT(20) DEFAULT NULL, + ts_last_modification BIGINT(20) DEFAULT NULL, + ts_last_update BIGINT(20) DEFAULT NULL, + process_info MEDIUMTEXT NOT NULL, + PRIMARY KEY (instance_uuid_hex) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_bin; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (167, NOW()); diff --git a/schema/mysql-migrations/upgrade_168.sql b/schema/mysql-migrations/upgrade_168.sql new file mode 100644 index 0000000..27934ae --- /dev/null +++ b/schema/mysql-migrations/upgrade_168.sql @@ -0,0 +1,21 @@ +CREATE TABLE director_datafield_category ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + category_name VARCHAR(255) NOT NULL, + description TEXT DEFAULT NULL, + PRIMARY KEY (id), + UNIQUE KEY category_name (category_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE director_datafield + ADD COLUMN category_id INT(10) UNSIGNED DEFAULT NULL AFTER id, + ADD CONSTRAINT director_datafield_category + FOREIGN KEY category (category_id) + REFERENCES director_datafield_category (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +; + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (168, NOW()); diff --git a/schema/mysql-migrations/upgrade_170.sql b/schema/mysql-migrations/upgrade_170.sql new file mode 100644 index 0000000..e259a79 --- /dev/null +++ b/schema/mysql-migrations/upgrade_170.sql @@ -0,0 +1,7 @@ + +ALTER TABLE sync_rule + MODIFY COLUMN update_policy ENUM('merge', 'override', 'ignore', 'update-only') NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (170, NOW()); diff --git a/schema/mysql-migrations/upgrade_171.sql b/schema/mysql-migrations/upgrade_171.sql new file mode 100644 index 0000000..76ab309 --- /dev/null +++ b/schema/mysql-migrations/upgrade_171.sql @@ -0,0 +1,3 @@ +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (171, NOW()); diff --git a/schema/mysql-migrations/upgrade_172.sql b/schema/mysql-migrations/upgrade_172.sql new file mode 100644 index 0000000..3af3571 --- /dev/null +++ b/schema/mysql-migrations/upgrade_172.sql @@ -0,0 +1,11 @@ +ALTER TABLE sync_rule + ADD COLUMN purge_action ENUM('delete', 'disable') NULL DEFAULT NULL AFTER purge_existing; + +UPDATE sync_rule SET purge_action = 'delete'; + +ALTER TABLE sync_rule + MODIFY COLUMN purge_action ENUM('delete', 'disable') DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (172, NOW()); diff --git a/schema/mysql-migrations/upgrade_173.sql b/schema/mysql-migrations/upgrade_173.sql new file mode 100644 index 0000000..609f783 --- /dev/null +++ b/schema/mysql-migrations/upgrade_173.sql @@ -0,0 +1,6 @@ +ALTER TABLE sync_rule + MODIFY COLUMN purge_action ENUM('delete', 'disable') NULL DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (173, NOW()); diff --git a/schema/mysql-migrations/upgrade_174.sql b/schema/mysql-migrations/upgrade_174.sql new file mode 100644 index 0000000..653cb42 --- /dev/null +++ b/schema/mysql-migrations/upgrade_174.sql @@ -0,0 +1,241 @@ +ALTER TABLE icinga_zone ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_zone SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_zone MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_timeperiod ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_timeperiod SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_timeperiod MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_command ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_command SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_command MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_apiuser ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_apiuser SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_apiuser MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_endpoint ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_endpoint SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_endpoint MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_host ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_host SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_host MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_service ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_service SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_service MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_hostgroup ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_hostgroup SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_hostgroup MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_servicegroup ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_servicegroup SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_servicegroup MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_user ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_user SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_user MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_usergroup ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_usergroup SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_usergroup MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_notification ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_notification SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_notification MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_dependency ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_dependency SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_dependency MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +ALTER TABLE icinga_scheduled_downtime ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_scheduled_downtime SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_scheduled_downtime MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (174, NOW()); diff --git a/schema/mysql-migrations/upgrade_175.sql b/schema/mysql-migrations/upgrade_175.sql new file mode 100644 index 0000000..b8a010f --- /dev/null +++ b/schema/mysql-migrations/upgrade_175.sql @@ -0,0 +1,484 @@ +CREATE TABLE director_branch ( + uuid VARBINARY(16) NOT NULL, + owner VARCHAR(255) NOT NULL, + branch_name VARCHAR(255) NOT NULL, + description TEXT DEFAULT NULL, + ts_merge_request BIGINT DEFAULT NULL, + PRIMARY KEY(uuid), + UNIQUE KEY (branch_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE director_branch_activity ( + timestamp_ns BIGINT(20) NOT NULL, + object_uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + action ENUM ('create', 'modify', 'delete') NOT NULL, + object_table VARCHAR(64) NOT NULL, + author VARCHAR(255) NOT NULL, + former_properties LONGTEXT NOT NULL, -- json-encoded + modified_properties LONGTEXT NOT NULL, + PRIMARY KEY (timestamp_ns), + INDEX object_uuid (object_uuid), + INDEX branch_uuid (branch_uuid), + CONSTRAINT branch_activity_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_host ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + address VARCHAR(255) DEFAULT NULL, + address6 VARCHAR(45) DEFAULT NULL, + check_command VARCHAR(255) DEFAULT NULL, + max_check_attempts MEDIUMINT UNSIGNED DEFAULT NULL, + check_period VARCHAR(255) DEFAULT NULL, + check_interval VARCHAR(8) DEFAULT NULL, + retry_interval VARCHAR(8) DEFAULT NULL, + check_timeout SMALLINT UNSIGNED DEFAULT NULL, + enable_notifications ENUM('y', 'n') DEFAULT NULL, + enable_active_checks ENUM('y', 'n') DEFAULT NULL, + enable_passive_checks ENUM('y', 'n') DEFAULT NULL, + enable_event_handler ENUM('y', 'n') DEFAULT NULL, + enable_flapping ENUM('y', 'n') DEFAULT NULL, + enable_perfdata ENUM('y', 'n') DEFAULT NULL, + event_command VARCHAR(255) DEFAULT NULL, + flapping_threshold_high SMALLINT UNSIGNED DEFAULT NULL, + flapping_threshold_low SMALLINT UNSIGNED DEFAULT NULL, + volatile ENUM('y', 'n') DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + command_endpoint VARCHAR(255) DEFAULT NULL, + notes TEXT DEFAULT NULL, + notes_url VARCHAR(255) DEFAULT NULL, + action_url VARCHAR(255) DEFAULT NULL, + icon_image VARCHAR(255) DEFAULT NULL, + icon_image_alt VARCHAR(255) DEFAULT NULL, + has_agent ENUM('y', 'n') DEFAULT NULL, + master_should_connect ENUM('y', 'n') DEFAULT NULL, + accept_config ENUM('y', 'n') DEFAULT NULL, + api_key VARCHAR(40) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + `groups` TEXT DEFAULT NULL, + vars MEDIUMTEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_host_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_hostgroup ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_hostgroup_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_servicegroup ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_servicegroup_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_usergroup ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_usergroup_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_user ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + email VARCHAR(255) DEFAULT NULL, + pager VARCHAR(255) DEFAULT NULL, + enable_notifications ENUM('y', 'n') DEFAULT NULL, + period VARCHAR(255) DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + states TEXT DEFAULT NULL, + types TEXT DEFAULT NULL, + + imports TEXT DEFAULT NULL, + `groups` TEXT DEFAULT NULL, + vars MEDIUMTEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_user_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_zone ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + parent VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + is_global ENUM('y', 'n') DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_zone_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_timeperiod ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + update_method VARCHAR(64) DEFAULT NULL COMMENT 'Usually LegacyTimePeriod', + zone VARCHAR(255) DEFAULT NULL, + prefer_includes ENUM('y', 'n') DEFAULT NULL, + + imports TEXT DEFAULT NULL, + ranges TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_timeperiod_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_command ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + methods_execute VARCHAR(64) DEFAULT NULL, + command TEXT DEFAULT NULL, + is_string ENUM('y', 'n') NULL, + timeout SMALLINT UNSIGNED DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + arguments TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_command_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_apiuser ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + password VARCHAR(255) DEFAULT NULL, + client_dn VARCHAR(64) DEFAULT NULL, + permissions TEXT DEFAULT NULL COMMENT 'JSON-encoded permissions', + + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_apiuser_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_endpoint ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + host VARCHAR(255) DEFAULT NULL, + port SMALLINT UNSIGNED DEFAULT NULL, + log_duration VARCHAR(32) DEFAULT NULL, + apiuser VARCHAR(255) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_endpoint_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_service ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + display_name VARCHAR(255) DEFAULT NULL, + host VARCHAR(255) DEFAULT NULL, + service_set VARCHAR(255) DEFAULT NULL, + check_command VARCHAR(255) DEFAULT NULL, + max_check_attempts MEDIUMINT UNSIGNED DEFAULT NULL, + check_period VARCHAR(255) DEFAULT NULL, + check_interval VARCHAR(8) DEFAULT NULL, + retry_interval VARCHAR(8) DEFAULT NULL, + check_timeout SMALLINT UNSIGNED DEFAULT NULL, + enable_notifications ENUM('y', 'n') DEFAULT NULL, + enable_active_checks ENUM('y', 'n') DEFAULT NULL, + enable_passive_checks ENUM('y', 'n') DEFAULT NULL, + enable_event_handler ENUM('y', 'n') DEFAULT NULL, + enable_flapping ENUM('y', 'n') DEFAULT NULL, + enable_perfdata ENUM('y', 'n') DEFAULT NULL, + event_command VARCHAR(255) DEFAULT NULL, + flapping_threshold_high SMALLINT UNSIGNED DEFAULT NULL, + flapping_threshold_low SMALLINT UNSIGNED DEFAULT NULL, + volatile ENUM('y', 'n') DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + command_endpoint VARCHAR(255) DEFAULT NULL, + notes TEXT DEFAULT NULL, + notes_url VARCHAR(255) DEFAULT NULL, + action_url VARCHAR(255) DEFAULT NULL, + icon_image VARCHAR(255) DEFAULT NULL, + icon_image_alt VARCHAR(255) DEFAULT NULL, + use_agent ENUM('y', 'n') DEFAULT NULL, + apply_for VARCHAR(255) DEFAULT NULL, + use_var_overrides ENUM('y', 'n') DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + -- template_choice VARCHAR(255) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + `groups` TEXT DEFAULT NULL, + vars MEDIUMTEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + INDEX search_object_name (object_name), + INDEX search_display_name (display_name), + CONSTRAINT icinga_service_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_notification ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + apply_to ENUM('host', 'service') DEFAULT NULL, + host VARCHAR(255) DEFAULT NULL, + service VARCHAR(255) DEFAULT NULL, + times_begin INT(10) UNSIGNED DEFAULT NULL, + times_end INT(10) UNSIGNED DEFAULT NULL, + notification_interval INT(10) UNSIGNED DEFAULT NULL, + command VARCHAR(255) DEFAULT NULL, + period VARCHAR(255) DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + + states TEXT DEFAULT NULL, + types TEXT DEFAULT NULL, + users TEXT DEFAULT NULL, + usergroups TEXT DEFAULT NULL, + + imports TEXT DEFAULT NULL, + vars MEDIUMTEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_notification_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_scheduled_downtime ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + apply_to ENUM('host', 'service') DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + author VARCHAR(255) DEFAULT NULL, + comment TEXT DEFAULT NULL, + fixed ENUM('y', 'n') DEFAULT NULL, + duration INT(10) UNSIGNED DEFAULT NULL, + with_services ENUM('y', 'n') NULL DEFAULT NULL, + + imports TEXT DEFAULT NULL, + ranges TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_scheduled_downtime_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE branched_icinga_dependency ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template', 'apply') DEFAULT NULL, + disabled ENUM('y', 'n') DEFAULT NULL, + apply_to ENUM('host', 'service') DEFAULT NULL, + parent_host VARCHAR(255) DEFAULT NULL, + parent_host_var VARCHAR(128) DEFAULT NULL, + parent_service VARCHAR(255) DEFAULT NULL, + child_host VARCHAR(255) DEFAULT NULL, + child_service VARCHAR(255) DEFAULT NULL, + disable_checks ENUM('y', 'n') DEFAULT NULL, + disable_notifications ENUM('y', 'n') DEFAULT NULL, + ignore_soft_states ENUM('y', 'n') DEFAULT NULL, + period VARCHAR(255) DEFAULT NULL, + zone VARCHAR(255) DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + parent_service_by_name VARCHAR(255) DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + UNIQUE INDEX branch_object_name (branch_uuid, object_name), + INDEX search_object_name (object_name), + CONSTRAINT icinga_dependency_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (175, NOW()); diff --git a/schema/mysql-migrations/upgrade_176.sql b/schema/mysql-migrations/upgrade_176.sql new file mode 100644 index 0000000..9913c11 --- /dev/null +++ b/schema/mysql-migrations/upgrade_176.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_host ADD COLUMN custom_endpoint_name VARCHAR(255) DEFAULT NULL AFTER accept_config; +ALTER TABLE branched_icinga_host ADD COLUMN custom_endpoint_name VARCHAR(255) DEFAULT NULL AFTER accept_config; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES ('176', NOW()); diff --git a/schema/mysql-migrations/upgrade_177.sql b/schema/mysql-migrations/upgrade_177.sql new file mode 100644 index 0000000..edceab0 --- /dev/null +++ b/schema/mysql-migrations/upgrade_177.sql @@ -0,0 +1,20 @@ +ALTER TABLE icinga_service_set ADD COLUMN uuid VARBINARY(16) DEFAULT NULL AFTER id; +SET @tmp_uuid = LOWER(CONCAT( + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), '-', + '4', + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + HEX(FLOOR(RAND() * 4 + 8)), + LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'), '-', + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0'), + LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0') +)); +UPDATE icinga_service_set SET uuid = UNHEX(LPAD(LPAD(HEX(id), 8, '0'), 32, REPLACE(@tmp_uuid, '-', ''))) WHERE uuid IS NULL; +ALTER TABLE icinga_service_set MODIFY COLUMN uuid VARBINARY(16) NOT NULL, ADD UNIQUE INDEX uuid (uuid); + + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES ('177', NOW()); diff --git a/schema/mysql-migrations/upgrade_178.sql b/schema/mysql-migrations/upgrade_178.sql new file mode 100644 index 0000000..589e604 --- /dev/null +++ b/schema/mysql-migrations/upgrade_178.sql @@ -0,0 +1,20 @@ +CREATE TABLE director_activity_log_remark ( + first_related_activity BIGINT(20) UNSIGNED NOT NULL, + last_related_activity BIGINT(20) UNSIGNED NOT NULL, + remark TEXT NOT NULL, + PRIMARY KEY (first_related_activity, last_related_activity), + CONSTRAINT activity_log_remark_begin + FOREIGN KEY first_related_activity (first_related_activity) + REFERENCES director_activity_log (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT activity_log_remark_end + FOREIGN KEY last_related_activity (last_related_activity) + REFERENCES director_activity_log (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES ('178', NOW()); diff --git a/schema/mysql-migrations/upgrade_179.sql b/schema/mysql-migrations/upgrade_179.sql new file mode 100644 index 0000000..8368b18 --- /dev/null +++ b/schema/mysql-migrations/upgrade_179.sql @@ -0,0 +1,5 @@ +ALTER TABLE director_deployment_log ADD INDEX (start_time); + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES ('179', NOW()); diff --git a/schema/mysql-migrations/upgrade_180.sql b/schema/mysql-migrations/upgrade_180.sql new file mode 100644 index 0000000..fb44365 --- /dev/null +++ b/schema/mysql-migrations/upgrade_180.sql @@ -0,0 +1,26 @@ +CREATE TABLE branched_icinga_service_set ( + uuid VARBINARY(16) NOT NULL, + branch_uuid VARBINARY(16) NOT NULL, + branch_created ENUM('y', 'n') NOT NULL DEFAULT 'n', + branch_deleted ENUM('y', 'n') NOT NULL DEFAULT 'n', + + object_name VARCHAR(128) DEFAULT NULL, + object_type ENUM('object', 'template', 'external_object') DEFAULT NULL, + host VARCHAR(255) DEFAULT NULL, + description TEXT DEFAULT NULL, + assign_filter TEXT DEFAULT NULL, + + imports TEXT DEFAULT NULL, + set_null TEXT DEFAULT NULL, + PRIMARY KEY (branch_uuid, uuid), + INDEX search_object_name (object_name), + CONSTRAINT icinga_service_set_branch + FOREIGN KEY branch (branch_uuid) + REFERENCES director_branch (uuid) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (180, NOW()); diff --git a/schema/mysql-migrations/upgrade_182.sql b/schema/mysql-migrations/upgrade_182.sql new file mode 100644 index 0000000..bb91fda --- /dev/null +++ b/schema/mysql-migrations/upgrade_182.sql @@ -0,0 +1,12 @@ +DELETE sr.* + FROM sync_run sr + JOIN sync_rule s ON s.id = sr.rule_id + WHERE sr.last_former_activity = sr.last_related_activity + AND s.object_type != 'datalistEntry' AND sr.start_time > '2022-09-21 00:00:00'; + +DELETE FROM sync_run + WHERE (objects_created + objects_deleted + objects_modified) = 0; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (182, NOW()); diff --git a/schema/mysql-migrations/upgrade_63.sql b/schema/mysql-migrations/upgrade_63.sql new file mode 100644 index 0000000..7d23612 --- /dev/null +++ b/schema/mysql-migrations/upgrade_63.sql @@ -0,0 +1,12 @@ +CREATE TABLE director_schema_migration ( + schema_version SMALLINT UNSIGNED NOT NULL, + migration_time DATETIME NOT NULL, + PRIMARY KEY(schema_version) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE director_dbversion; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 63; + diff --git a/schema/mysql-migrations/upgrade_64.sql b/schema/mysql-migrations/upgrade_64.sql new file mode 100644 index 0000000..ded1a0c --- /dev/null +++ b/schema/mysql-migrations/upgrade_64.sql @@ -0,0 +1,10 @@ +CREATE TABLE director_setting ( + setting_name VARCHAR(64) NOT NULL, + setting_value VARCHAR(255) NOT NULL, + PRIMARY KEY(setting_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 64; + diff --git a/schema/mysql-migrations/upgrade_65.sql b/schema/mysql-migrations/upgrade_65.sql new file mode 100644 index 0000000..7c23c91 --- /dev/null +++ b/schema/mysql-migrations/upgrade_65.sql @@ -0,0 +1,37 @@ +ALTER TABLE icinga_zone + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_timeperiod + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_command + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_apiuser + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_endpoint + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_host + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_service + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_hostgroup + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_servicegroup + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_user + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +ALTER TABLE icinga_usergroup + ADD COLUMN disabled ENUM('y', 'n') NOT NULL DEFAULT 'n' AFTER object_type; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 65; + diff --git a/schema/mysql-migrations/upgrade_66.sql b/schema/mysql-migrations/upgrade_66.sql new file mode 100644 index 0000000..9ce2cd8 --- /dev/null +++ b/schema/mysql-migrations/upgrade_66.sql @@ -0,0 +1,37 @@ + +-- dropping old tables, as they have never been used + +DROP TABLE import_row_modifier_setting; +DROP TABLE import_row_modifier; + +CREATE TABLE import_row_modifier ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + source_id INT(10) UNSIGNED NOT NULL, + property_name VARCHAR(255) NOT NULL, + provider_class VARCHAR(72) NOT NULL, + priority SMALLINT UNSIGNED NOT NULL, + PRIMARY KEY (id), + KEY search_idx (property_name), + CONSTRAINT row_modifier_import_source + FOREIGN KEY source (source_id) + REFERENCES import_source (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE import_row_modifier_setting ( + row_modifier_id INT UNSIGNED NOT NULL, + setting_name VARCHAR(64) NOT NULL, + setting_value TEXT DEFAULT NULL, + PRIMARY KEY (row_modifier_id, setting_name), + CONSTRAINT row_modifier_settings + FOREIGN KEY row_modifier (row_modifier_id) + REFERENCES import_row_modifier (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 66; + diff --git a/schema/mysql-migrations/upgrade_67.sql b/schema/mysql-migrations/upgrade_67.sql new file mode 100644 index 0000000..4bbb1b9 --- /dev/null +++ b/schema/mysql-migrations/upgrade_67.sql @@ -0,0 +1,23 @@ +CREATE TABLE sync_run ( + id BIGINT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + rule_id INT(10) UNSIGNED DEFAULT NULL, + rule_name VARCHAR(255) NOT NULL, + start_time DATETIME NOT NULL, + duration_ms INT(10) UNSIGNED NOT NULL, + objects_deleted INT(10) UNSIGNED DEFAULT 0, + objects_created INT(10) UNSIGNED DEFAULT 0, + objects_modified INT(10) UNSIGNED DEFAULT 0, + first_related_activity VARBINARY(20) DEFAULT NULL, + last_related_activity VARBINARY(20) DEFAULT NULL, + PRIMARY KEY (id), + CONSTRAINT sync_run_rule + FOREIGN KEY sync_rule (rule_id) + REFERENCES sync_rule (id) + ON DELETE SET NULL + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 67; + diff --git a/schema/mysql-migrations/upgrade_68.sql b/schema/mysql-migrations/upgrade_68.sql new file mode 100644 index 0000000..d2318b8 --- /dev/null +++ b/schema/mysql-migrations/upgrade_68.sql @@ -0,0 +1,6 @@ +ALTER TABLE sync_run MODIFY duration_ms INT(10) UNSIGNED DEFAULT NULL; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 68; + diff --git a/schema/mysql-migrations/upgrade_69.sql b/schema/mysql-migrations/upgrade_69.sql new file mode 100644 index 0000000..7bf764e --- /dev/null +++ b/schema/mysql-migrations/upgrade_69.sql @@ -0,0 +1,9 @@ +ALTER TABLE sync_run + DROP COLUMN first_related_activity, + ADD COLUMN last_former_activity VARBINARY(20) DEFAULT NULL AFTER objects_modified; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 69; + + diff --git a/schema/mysql-migrations/upgrade_70.sql b/schema/mysql-migrations/upgrade_70.sql new file mode 100644 index 0000000..1312c02 --- /dev/null +++ b/schema/mysql-migrations/upgrade_70.sql @@ -0,0 +1,13 @@ +ALTER TABLE icinga_timeperiod_range + DROP FOREIGN KEY icinga_timeperiod_range_timeperiod; + +ALTER TABLE icinga_timeperiod_range + ADD CONSTRAINT icinga_timeperiod_range_timeperiod + FOREIGN KEY timeperiod (timeperiod_id) + REFERENCES icinga_timeperiod (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 70; diff --git a/schema/mysql-migrations/upgrade_71.sql b/schema/mysql-migrations/upgrade_71.sql new file mode 100644 index 0000000..87dbce1 --- /dev/null +++ b/schema/mysql-migrations/upgrade_71.sql @@ -0,0 +1,44 @@ +CREATE TABLE icinga_notification ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + object_name VARCHAR(255) DEFAULT NULL, + object_type ENUM('object', 'template') NOT NULL, + disabled ENUM('y', 'n') NOT NULL DEFAULT 'n', + host_id INT(10) UNSIGNED DEFAULT NULL, + service_id INT(10) UNSIGNED DEFAULT NULL, + times_begin INT(10) UNSIGNED DEFAULT NULL, + times_end INT(10) UNSIGNED DEFAULT NULL, + notification_interval INT(10) UNSIGNED DEFAULT NULL, + command_id INT(10) UNSIGNED DEFAULT NULL, + period_id INT(10) UNSIGNED DEFAULT NULL, + zone_id INT(10) UNSIGNED DEFAULT NULL, + PRIMARY KEY (id), + CONSTRAINT icinga_notification_host + FOREIGN KEY host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_command + FOREIGN KEY command (command_id) + REFERENCES icinga_command (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_period + FOREIGN KEY period (period_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_zone + FOREIGN KEY zone (zone_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 71; diff --git a/schema/mysql-migrations/upgrade_72.sql b/schema/mysql-migrations/upgrade_72.sql new file mode 100644 index 0000000..82aa478 --- /dev/null +++ b/schema/mysql-migrations/upgrade_72.sql @@ -0,0 +1,14 @@ + +ALTER TABLE director_generated_config + ADD COLUMN first_activity_checksum VARBINARY(20) NOT NULL AFTER duration; + +UPDATE director_generated_config SET first_activity_checksum = last_activity_checksum; + +ALTER TABLE director_deployment_log + ADD COLUMN last_activity_checksum VARBINARY(20) NOT NULL AFTER config_checksum; + +UPDATE director_deployment_log l JOIN director_generated_config c ON l.config_checksum = c.checksum SET l.last_activity_checksum = c.last_activity_checksum; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 72; diff --git a/schema/mysql-migrations/upgrade_73.sql b/schema/mysql-migrations/upgrade_73.sql new file mode 100644 index 0000000..ecf27ae --- /dev/null +++ b/schema/mysql-migrations/upgrade_73.sql @@ -0,0 +1,50 @@ +DROP TABLE icinga_user_filter_state; + +CREATE TABLE icinga_user_states_set ( + user_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'OK', + 'Warning', + 'Critical', + 'Unknown', + 'Up', + 'Down' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (user_id, property), + CONSTRAINT icinga_user_states_set_user + FOREIGN KEY icinga_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +DROP TABLE icinga_user_filter_type; + +CREATE TABLE icinga_user_filters_set ( + user_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'DowntimeStart', + 'DowntimeEnd', + 'DowntimeRemoved', + 'Custom', + 'Acknowledgement', + 'Problem', + 'Recovery', + 'FlappingStart', + 'FlappingEnd' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (user_id, property), + CONSTRAINT icinga_user_filters_set_user + FOREIGN KEY icinga_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 73; diff --git a/schema/mysql-migrations/upgrade_74.sql b/schema/mysql-migrations/upgrade_74.sql new file mode 100644 index 0000000..382f937 --- /dev/null +++ b/schema/mysql-migrations/upgrade_74.sql @@ -0,0 +1,14 @@ + +ALTER TABLE icinga_service + DROP FOREIGN KEY icinga_host; + +ALTER TABLE icinga_service + ADD CONSTRAINT icinga_service_host + FOREIGN KEY host (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 74; diff --git a/schema/mysql-migrations/upgrade_75.sql b/schema/mysql-migrations/upgrade_75.sql new file mode 100644 index 0000000..4afcab0 --- /dev/null +++ b/schema/mysql-migrations/upgrade_75.sql @@ -0,0 +1,50 @@ +DROP TABLE icinga_user_states_set; + +CREATE TABLE icinga_user_states_set ( + user_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'OK', + 'Warning', + 'Critical', + 'Unknown', + 'Up', + 'Down' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (user_id, property, merge_behaviour), + CONSTRAINT icinga_user_states_set_user + FOREIGN KEY icinga_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +DROP TABLE icinga_user_filters_set; + +CREATE TABLE icinga_user_filters_set ( + user_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'DowntimeStart', + 'DowntimeEnd', + 'DowntimeRemoved', + 'Custom', + 'Acknowledgement', + 'Problem', + 'Recovery', + 'FlappingStart', + 'FlappingEnd' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (user_id, property, merge_behaviour), + CONSTRAINT icinga_user_filters_set_user + FOREIGN KEY icinga_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 75; diff --git a/schema/mysql-migrations/upgrade_76.sql b/schema/mysql-migrations/upgrade_76.sql new file mode 100644 index 0000000..a2c1d51 --- /dev/null +++ b/schema/mysql-migrations/upgrade_76.sql @@ -0,0 +1,28 @@ +DROP TABLE icinga_user_filters_set; + +CREATE TABLE icinga_user_types_set ( + user_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'DowntimeStart', + 'DowntimeEnd', + 'DowntimeRemoved', + 'Custom', + 'Acknowledgement', + 'Problem', + 'Recovery', + 'FlappingStart', + 'FlappingEnd' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (user_id, property, merge_behaviour), + CONSTRAINT icinga_user_types_set_user + FOREIGN KEY icinga_user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 76; diff --git a/schema/mysql-migrations/upgrade_77.sql b/schema/mysql-migrations/upgrade_77.sql new file mode 100644 index 0000000..0b60cc5 --- /dev/null +++ b/schema/mysql-migrations/upgrade_77.sql @@ -0,0 +1,78 @@ +CREATE TABLE icinga_notification_states_set ( + notification_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'OK', + 'Warning', + 'Critical', + 'Unknown', + 'Up', + 'Down' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (notification_id, property, merge_behaviour), + CONSTRAINT icinga_notification_states_set_notification + FOREIGN KEY icinga_notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE icinga_notification_types_set ( + notification_id INT(10) UNSIGNED NOT NULL, + property ENUM( + 'DowntimeStart', + 'DowntimeEnd', + 'DowntimeRemoved', + 'Custom', + 'Acknowledgement', + 'Problem', + 'Recovery', + 'FlappingStart', + 'FlappingEnd' + ) NOT NULL, + merge_behaviour ENUM('override', 'extend', 'blacklist') NOT NULL DEFAULT 'override' + COMMENT 'override: = [], extend: += [], blacklist: -= []', + PRIMARY KEY (notification_id, property, merge_behaviour), + CONSTRAINT icinga_notification_types_set_notification + FOREIGN KEY icinga_notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE icinga_notification_var ( + notification_id INT(10) UNSIGNED NOT NULL, + varname VARCHAR(255) DEFAULT NULL, + varvalue TEXT DEFAULT NULL, + format enum ('string', 'json', 'expression'), + PRIMARY KEY (notification_id, varname), + key search_idx (varname), + CONSTRAINT icinga_notification_var_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_notification_inheritance ( + notification_id INT(10) UNSIGNED NOT NULL, + parent_notification_id INT(10) UNSIGNED NOT NULL, + weight MEDIUMINT UNSIGNED DEFAULT NULL, + PRIMARY KEY (notification_id, parent_notification_id), + UNIQUE KEY unique_order (notification_id, weight), + CONSTRAINT icinga_notification_inheritance_notification + FOREIGN KEY host (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_inheritance_parent_notification + FOREIGN KEY host (parent_notification_id) + REFERENCES icinga_notification (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 77; diff --git a/schema/mysql-migrations/upgrade_78.sql b/schema/mysql-migrations/upgrade_78.sql new file mode 100644 index 0000000..5988ff6 --- /dev/null +++ b/schema/mysql-migrations/upgrade_78.sql @@ -0,0 +1,20 @@ +CREATE TABLE icinga_user_field ( + user_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + datafield_id INT(10) UNSIGNED NOT NULL, + is_required ENUM('y', 'n') NOT NULL, + PRIMARY KEY (user_id, datafield_id), + CONSTRAINT icinga_user_field_user + FOREIGN KEY user(user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_user_field_datafield + FOREIGN KEY datafield(datafield_id) + REFERENCES director_datafield (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 78; diff --git a/schema/mysql-migrations/upgrade_82.sql b/schema/mysql-migrations/upgrade_82.sql new file mode 100644 index 0000000..e1acff8 --- /dev/null +++ b/schema/mysql-migrations/upgrade_82.sql @@ -0,0 +1,17 @@ +ALTER TABLE sync_rule + MODIFY COLUMN object_type enum( + 'host', + 'service', + 'command', + 'user', + 'hostgroup', + 'servicegroup', + 'usergroup', + 'datalistEntry', + 'endpoint', + 'zone' + ) NOT NULL; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 82; diff --git a/schema/mysql-migrations/upgrade_84.sql b/schema/mysql-migrations/upgrade_84.sql new file mode 100644 index 0000000..1de287a --- /dev/null +++ b/schema/mysql-migrations/upgrade_84.sql @@ -0,0 +1,5 @@ +ALTER TABLE icinga_usergroup DROP COLUMN zone_id; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (84, NOW()); diff --git a/schema/mysql-migrations/upgrade_85.sql b/schema/mysql-migrations/upgrade_85.sql new file mode 100644 index 0000000..186e171 --- /dev/null +++ b/schema/mysql-migrations/upgrade_85.sql @@ -0,0 +1,15 @@ +CREATE TABLE icinga_notification_assignment ( + id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + notification_id INT(10) UNSIGNED NOT NULL, + filter_string TEXT NOT NULL, + PRIMARY KEY (id), + CONSTRAINT icinga_notification_assignment + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (85, NOW()); diff --git a/schema/mysql-migrations/upgrade_86.sql b/schema/mysql-migrations/upgrade_86.sql new file mode 100644 index 0000000..58b81c0 --- /dev/null +++ b/schema/mysql-migrations/upgrade_86.sql @@ -0,0 +1,35 @@ +CREATE TABLE icinga_notification_user ( + notification_id INT(10) UNSIGNED NOT NULL, + user_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (notification_id, user_id), + CONSTRAINT icinga_notification_user_user + FOREIGN KEY user (user_id) + REFERENCES icinga_user (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_user_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_notification_usergroup ( + notification_id INT(10) UNSIGNED NOT NULL, + usergroup_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (notification_id, usergroup_id), + CONSTRAINT icinga_notification_usergroup_usergroup + FOREIGN KEY usergroup (usergroup_id) + REFERENCES icinga_usergroup (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_notification_usergroup_notification + FOREIGN KEY notification (notification_id) + REFERENCES icinga_notification (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (86, NOW()); diff --git a/schema/mysql-migrations/upgrade_87.sql b/schema/mysql-migrations/upgrade_87.sql new file mode 100644 index 0000000..a6da21f --- /dev/null +++ b/schema/mysql-migrations/upgrade_87.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_notification + MODIFY COLUMN object_type ENUM('object', 'template', 'apply') NOT NULL; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 87; diff --git a/schema/mysql-migrations/upgrade_89.sql b/schema/mysql-migrations/upgrade_89.sql new file mode 100644 index 0000000..cf6ac20 --- /dev/null +++ b/schema/mysql-migrations/upgrade_89.sql @@ -0,0 +1,6 @@ +ALTER TABLE icinga_command_argument + ADD required ENUM('y', 'n') DEFAULT NULL AFTER repeat_key; + +INSERT INTO director_schema_migration + SET migration_time = NOW(), + schema_version = 89; diff --git a/schema/mysql-migrations/upgrade_90.sql b/schema/mysql-migrations/upgrade_90.sql new file mode 100644 index 0000000..e3ef4fb --- /dev/null +++ b/schema/mysql-migrations/upgrade_90.sql @@ -0,0 +1,5 @@ +ALTER TABLE icinga_service_assignment ADD assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign'; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (90, NOW()); diff --git a/schema/mysql-migrations/upgrade_91.sql b/schema/mysql-migrations/upgrade_91.sql new file mode 100644 index 0000000..88a551f --- /dev/null +++ b/schema/mysql-migrations/upgrade_91.sql @@ -0,0 +1,5 @@ +ALTER TABLE icinga_notification_assignment ADD assign_type ENUM('assign', 'ignore') NOT NULL DEFAULT 'assign'; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (91, NOW()); diff --git a/schema/mysql-migrations/upgrade_92.sql b/schema/mysql-migrations/upgrade_92.sql new file mode 100644 index 0000000..b7d2503 --- /dev/null +++ b/schema/mysql-migrations/upgrade_92.sql @@ -0,0 +1,27 @@ +DELETE FROM director_datalist_entry WHERE entry_name IS NULL; +ALTER TABLE director_datalist_entry + MODIFY entry_name VARCHAR(255) NOT NULL; + +DELETE FROM icinga_command_var WHERE varname IS NULL; +ALTER TABLE icinga_command_var + MODIFY varname VARCHAR(255) NOT NULL; + +DELETE FROM icinga_host_var WHERE varname IS NULL; +ALTER TABLE icinga_host_var + MODIFY varname VARCHAR(255) NOT NULL; + +DELETE FROM icinga_service_var WHERE varname IS NULL; +ALTER TABLE icinga_service_var + MODIFY varname VARCHAR(255) NOT NULL; + +DELETE FROM icinga_user_var WHERE varname IS NULL; +ALTER TABLE icinga_user_var + MODIFY varname VARCHAR(255) NOT NULL; + +DELETE FROM icinga_notification_var WHERE varname IS NULL; +ALTER TABLE icinga_notification_var + MODIFY varname VARCHAR(255) NOT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (92, NOW()); diff --git a/schema/mysql-migrations/upgrade_93.sql b/schema/mysql-migrations/upgrade_93.sql new file mode 100644 index 0000000..845d4bf --- /dev/null +++ b/schema/mysql-migrations/upgrade_93.sql @@ -0,0 +1,22 @@ +ALTER TABLE sync_rule + ADD COLUMN sync_state ENUM( + 'unknown', + 'in-sync', + 'pending-changes', + 'failing' + ) NOT NULL DEFAULT 'unknown', + ADD COLUMN last_error_message VARCHAR(255) DEFAULT NULL, + ADD COLUMN last_attempt DATETIME DEFAULT NULL +; + +UPDATE sync_rule r + JOIN ( + SELECT rule_id, MAX(start_time) AS start_time + FROM sync_run + GROUP BY rule_id + ) lr ON r.id = lr.rule_id + SET r.last_attempt = lr.start_time; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (93, NOW()); diff --git a/schema/mysql-migrations/upgrade_94.sql b/schema/mysql-migrations/upgrade_94.sql new file mode 100644 index 0000000..5b55b37 --- /dev/null +++ b/schema/mysql-migrations/upgrade_94.sql @@ -0,0 +1,29 @@ +CREATE TABLE director_job ( + id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, + job_name VARCHAR(64) NOT NULL, + job_class VARCHAR(72) NOT NULL, + disabled ENUM('y', 'n') NOT NULL DEFAULT 'n', + run_interval INT(10) UNSIGNED NOT NULL, -- seconds + last_attempt_succeeded ENUM('y', 'n') DEFAULT NULL, + ts_last_attempt DATETIME DEFAULT NULL, + ts_last_error DATETIME DEFAULT NULL, + last_error_message TEXT, + PRIMARY KEY (id), + UNIQUE KEY (job_name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE director_job_setting ( + job_id INT UNSIGNED NOT NULL, + setting_name VARCHAR(64) NOT NULL, + setting_value TEXT DEFAULT NULL, + PRIMARY KEY (job_id, setting_name), + CONSTRAINT job_settings + FOREIGN KEY director_job (job_id) + REFERENCES director_job (id) + ON DELETE CASCADE + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (94, NOW()); diff --git a/schema/mysql-migrations/upgrade_95.sql b/schema/mysql-migrations/upgrade_95.sql new file mode 100644 index 0000000..aa49c5b --- /dev/null +++ b/schema/mysql-migrations/upgrade_95.sql @@ -0,0 +1,22 @@ +ALTER TABLE import_source + ADD COLUMN import_state ENUM( + 'unknown', + 'in-sync', + 'pending-changes', + 'failing' + ) NOT NULL DEFAULT 'unknown', + ADD COLUMN last_error_message TEXT DEFAULT NULL, + ADD COLUMN last_attempt DATETIME DEFAULT NULL +; + +UPDATE import_source s + JOIN ( + SELECT source_id, MAX(start_time) AS start_time + FROM import_run + GROUP BY source_id + ) ir ON s.id = ir.source_id + SET s.last_attempt = ir.start_time; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (95, NOW()); diff --git a/schema/mysql-migrations/upgrade_96.sql b/schema/mysql-migrations/upgrade_96.sql new file mode 100644 index 0000000..de96582 --- /dev/null +++ b/schema/mysql-migrations/upgrade_96.sql @@ -0,0 +1,5 @@ +ALTER TABLE icinga_notification ADD apply_to ENUM('host', 'service') DEFAULT NULL AFTER disabled; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (96, NOW()); diff --git a/schema/mysql-migrations/upgrade_97.sql b/schema/mysql-migrations/upgrade_97.sql new file mode 100644 index 0000000..7da33b2 --- /dev/null +++ b/schema/mysql-migrations/upgrade_97.sql @@ -0,0 +1,11 @@ +ALTER TABLE director_job + ADD COLUMN timeperiod_id INT(10) UNSIGNED DEFAULT NULL AFTER run_interval, + ADD CONSTRAINT director_job_period + FOREIGN KEY timeperiod (timeperiod_id) + REFERENCES icinga_timeperiod (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (97, NOW()); |