Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
IDO: Import 1.14.0 schema updates
Browse files Browse the repository at this point in the history
fixes #9047
fixes #9832
  • Loading branch information
Michael Friedrich committed Oct 30, 2015
1 parent 028eca6 commit a3b767a
Show file tree
Hide file tree
Showing 9 changed files with 512 additions and 105 deletions.
51 changes: 48 additions & 3 deletions module/idoutils/db/mysql/mysql.sql
Expand Up @@ -82,6 +82,7 @@ CREATE TABLE IF NOT EXISTS icinga_commenthistory (
expiration_time timestamp default '0000-00-00 00:00:00',
deletion_time timestamp default '0000-00-00 00:00:00',
deletion_time_usec int default 0,
unique_id TEXT character set latin1 default NULL,
PRIMARY KEY (commenthistory_id),
UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
) ENGINE=InnoDB COMMENT='Historical host and service comments';
Expand All @@ -108,6 +109,7 @@ CREATE TABLE IF NOT EXISTS icinga_comments (
comment_source smallint default 0,
expires smallint default 0,
expiration_time timestamp default '0000-00-00 00:00:00',
unique_id TEXT character set latin1 default NULL,
PRIMARY KEY (comment_id),
UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
) ENGINE=InnoDB COMMENT='Usercomments on Icinga objects';
Expand Down Expand Up @@ -340,6 +342,7 @@ CREATE TABLE IF NOT EXISTS icinga_customvariables (
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
is_json smallint default 0,
session_token varchar(512) character set latin1 default NULL,
PRIMARY KEY (customvariable_id),
UNIQUE KEY object_id_2 (object_id,config_type,varname),
KEY varname (varname)
Expand All @@ -360,6 +363,7 @@ CREATE TABLE IF NOT EXISTS icinga_customvariablestatus (
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
is_json smallint default 0,
session_token varchar(512) character set latin1 default NULL,
PRIMARY KEY (customvariablestatus_id),
UNIQUE KEY object_id_2 (object_id,varname),
KEY varname (varname)
Expand Down Expand Up @@ -409,6 +413,7 @@ CREATE TABLE IF NOT EXISTS icinga_downtimehistory (
was_cancelled smallint default 0,
is_in_effect smallint default 0,
trigger_time timestamp default '0000-00-00 00:00:00',
unique_id TEXT character set latin1 default NULL,
PRIMARY KEY (downtimehistory_id),
UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
) ENGINE=InnoDB COMMENT='Historical scheduled host and service downtime';
Expand Down Expand Up @@ -666,7 +671,7 @@ CREATE TABLE IF NOT EXISTS icinga_hosts (
high_flap_threshold double default '0',
process_performance_data smallint default 0,
freshness_checks_enabled smallint default 0,
freshness_threshold smallint default 0,
freshness_threshold int default 0,
passive_checks_enabled smallint default 0,
event_handler_enabled smallint default 0,
active_checks_enabled smallint default 0,
Expand Down Expand Up @@ -744,6 +749,7 @@ CREATE TABLE IF NOT EXISTS icinga_hoststatus (
process_performance_data smallint default 0,
obsess_over_host smallint default 0,
modified_host_attributes int default 0,
original_attributes TEXT character set latin1 default NULL,
event_handler TEXT character set latin1 default '',
check_command TEXT character set latin1 default '',
normal_check_interval double default '0',
Expand Down Expand Up @@ -969,6 +975,7 @@ CREATE TABLE IF NOT EXISTS icinga_scheduleddowntime (
actual_start_time_usec int default 0,
is_in_effect smallint default 0,
trigger_time timestamp default '0000-00-00 00:00:00',
unique_id TEXT character set latin1 default NULL,
PRIMARY KEY (scheduleddowntime_id),
UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
) ENGINE=InnoDB COMMENT='Current scheduled host and service downtime';
Expand Down Expand Up @@ -1160,7 +1167,7 @@ CREATE TABLE IF NOT EXISTS icinga_services (
high_flap_threshold double default '0',
process_performance_data smallint default 0,
freshness_checks_enabled smallint default 0,
freshness_threshold smallint default 0,
freshness_threshold int default 0,
passive_checks_enabled smallint default 0,
event_handler_enabled smallint default 0,
active_checks_enabled smallint default 0,
Expand Down Expand Up @@ -1230,6 +1237,7 @@ CREATE TABLE IF NOT EXISTS icinga_servicestatus (
process_performance_data smallint default 0,
obsess_over_service smallint default 0,
modified_service_attributes int default 0,
original_attributes TEXT character set latin1 default NULL,
event_handler TEXT character set latin1 default '',
check_command TEXT character set latin1 default '',
normal_check_interval double default '0',
Expand Down Expand Up @@ -1362,6 +1370,7 @@ CREATE TABLE IF NOT EXISTS icinga_endpoints (
endpoint_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
endpoint_object_id bigint(20) unsigned DEFAULT '0',
zone_object_id bigint(20) unsigned DEFAULT '0',
config_type smallint(6) DEFAULT '0',
identity varchar(255) DEFAULT NULL,
node varchar(255) DEFAULT NULL,
Expand All @@ -1378,13 +1387,45 @@ CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
endpointstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
endpoint_object_id bigint(20) unsigned DEFAULT '0',
zone_object_id bigint(20) unsigned DEFAULT '0',
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
identity varchar(255) DEFAULT NULL,
node varchar(255) DEFAULT NULL,
is_connected smallint(6),
PRIMARY KEY (endpointstatus_id)
) ENGINE=InnoDB COMMENT='Endpoint status';

--
-- Table structure for table icinga_zones
--

CREATE TABLE IF NOT EXISTS icinga_zones (
zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
zone_object_id bigint(20) unsigned DEFAULT '0',
config_type smallint(6) DEFAULT '0',
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
is_global smallint(6),
PRIMARY KEY (zone_id)
) ENGINE=InnoDB COMMENT='Zone configuration';

-- --------------------------------------------------------

--
-- Table structure for table icinga_zonestatus
--

CREATE TABLE IF NOT EXISTS icinga_zonestatus (
zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
zone_object_id bigint(20) unsigned DEFAULT '0',
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
PRIMARY KEY (zonestatus_id)
) ENGINE=InnoDB COMMENT='Zone status';




ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
Expand Down Expand Up @@ -1600,9 +1641,13 @@ CREATE INDEX sla_idx_obj ON icinga_objects (objecttype_id, is_active, name1);
-- #4985
CREATE INDEX commenthistory_delete_idx ON icinga_commenthistory (instance_id, comment_time, internal_comment_id);

-- #10436
CREATE INDEX cv_session_del_idx ON icinga_customvariables (session_token);
CREATE INDEX cvs_session_del_idx ON icinga_customvariablestatus (session_token);

-- -----------------------------------------
-- set dbversion
-- -----------------------------------------
INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.13.0', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.13.0', modify_time=NOW();
INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.0', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.14.0', modify_time=NOW();


75 changes: 75 additions & 0 deletions module/idoutils/db/mysql/upgrade/mysql-upgrade-1.14.0.sql
@@ -0,0 +1,75 @@
-- -----------------------------------------
-- upgrade path for Icinga 2.4.0
--
-- -----------------------------------------
-- Copyright (c) 2015 Icinga Development Team (http://www.icinga.org)
--
-- Please check http://docs.icinga.org for upgrading information!
-- -----------------------------------------

-- -----------------------------------------
-- #9286 - zone tables
-- -----------------------------------------

ALTER TABLE icinga_endpoints ADD COLUMN zone_object_id bigint(20) unsigned DEFAULT '0';
ALTER TABLE icinga_endpointstatus ADD COLUMN zone_object_id bigint(20) unsigned DEFAULT '0';

CREATE TABLE IF NOT EXISTS icinga_zones (
zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
zone_object_id bigint(20) unsigned DEFAULT '0',
config_type smallint(6) DEFAULT '0',
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
is_global smallint(6),
PRIMARY KEY (zone_id)
) ENGINE=InnoDB COMMENT='Zone configuration';

CREATE TABLE IF NOT EXISTS icinga_zonestatus (
zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
instance_id bigint unsigned default 0,
zone_object_id bigint(20) unsigned DEFAULT '0',
status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
parent_zone_object_id bigint(20) unsigned DEFAULT '0',
PRIMARY KEY (zonestatus_id)
) ENGINE=InnoDB COMMENT='Zone status';


-- -----------------------------------------
-- #9576 - freshness_threshold
-- -----------------------------------------

ALTER TABLE icinga_services MODIFY freshness_threshold int;
ALTER TABLE icinga_hosts MODIFY freshness_threshold int;

-- -----------------------------------------
-- #10392 - original attributes
-- -----------------------------------------

ALTER TABLE icinga_servicestatus ADD COLUMN original_attributes TEXT character set latin1 default NULL;
ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT character set latin1 default NULL;

-- -----------------------------------------
-- #10436 deleted custom vars
-- -----------------------------------------

ALTER TABLE icinga_customvariables ADD COLUMN session_token varchar(512) character set latin1 default NULL;
ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token varchar(512) character set latin1 default NULL;

CREATE INDEX cv_session_del_idx ON icinga_customvariables (session_token);
CREATE INDEX cvs_session_del_idx ON icinga_customvariablestatus (session_token);

-- -----------------------------------------
-- #10431 comment/downtime unique id
-- -----------------------------------------

ALTER TABLE icinga_comments ADD COLUMN unique_id TEXT character set latin1 default NULL;
ALTER TABLE icinga_commenthistory ADD COLUMN unique_id TEXT character set latin1 default NULL;

ALTER TABLE icinga_scheduleddowntime ADD COLUMN unique_id TEXT character set latin1 default NULL;
ALTER TABLE icinga_downtimehistory ADD COLUMN unique_id TEXT character set latin1 default NULL;

-- -----------------------------------------
-- update dbversion
-- -----------------------------------------

INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.0', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.14.0', modify_time=NOW();
2 changes: 1 addition & 1 deletion module/idoutils/db/oracle/oracle.sql
Expand Up @@ -17,7 +17,7 @@
-- -- --------------------------------------------------------
*/

DEFINE ICINGA_VERSION=1.13.0
DEFINE ICINGA_VERSION=1.14.0

-- -----------------------------------------
-- set defines
Expand Down
57 changes: 57 additions & 0 deletions module/idoutils/db/oracle/upgrade/oracle-upgrade-1.14.0.sql
@@ -0,0 +1,57 @@
-- -----------------------------------------
-- upgrade path for Icinga IDOUtils 1.14.0
--
-- run it as icinga database user from whithin current directory
-- sqlplus icinga@<instance> @ oracle-upgrade-1.14.0.sql

-- -----------------------------------------
-- Copyright (c) 2014 Icinga Development Team (http://www.icinga.org)
--
-- Please check http://docs.icinga.org for upgrading information!
-- -----------------------------------------
set sqlprompt "&&_USER@&&_CONNECT_IDENTIFIER SQL>"
set pagesize 200;
set linesize 200;
set heading on;
set echo on;
set feedback on;

define ICINGA_VERSION=1.14.0

-- --------------------------------------------------------
-- warning: edit this script to define existing tablespaces
-- this particular step can be skipped safely if no new
-- table or index included
-- --------------------------------------------------------
/* set real TBS names on which you have quota, no checks are implemented!*/
define DATATBS='ICINGA_DATA1';
define LOBTBS='ICINGA_LOB1';
define IDXTBS='ICINGA_IDX1';

/* load defines from file, if any */
@icinga_defines.sql

/* script will be terminated on the first error */
whenever sqlerror exit failure
spool oracle-upgrade-&&ICINGA_VERSION..log


-- -----------------------------------------
-- finally update dbversion
-- -----------------------------------------

MERGE INTO dbversion
USING DUAL ON (name='idoutils')
WHEN MATCHED THEN
UPDATE SET version='&&ICINGA_VERSION', modify_time=CURRENT_TIMESTAMP
WHEN NOT MATCHED THEN
INSERT (id, name, version, create_time, modify_time) VALUES ('1', 'idoutils', '&&ICINGA_VERSION', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
commit;

/* last check */
select object_name,object_type,status from user_objects where status !='VALID';

/* goodbye */
spool off
exit;

0 comments on commit a3b767a

Please sign in to comment.