From 1b9f0a8c77b3c00f87f9ee0e9515098c7b0ab4fb Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 30 Oct 2015 11:24:48 +0100 Subject: [PATCH] Add the unique_id for comments/downtimes next to legacy_id to DB IDO fixes #10431 --- lib/db_ido/dbevents.cpp | 2 ++ lib/db_ido_mysql/schema/mysql.sql | 4 ++++ lib/db_ido_mysql/schema/upgrade/2.4.0.sql | 10 ++++++++++ lib/db_ido_pgsql/schema/pgsql.sql | 4 ++++ lib/db_ido_pgsql/schema/upgrade/2.4.0.sql | 12 ++++++++++++ 5 files changed, 32 insertions(+) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 0da037c77..50ecf47a4 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -353,6 +353,7 @@ void DbEvents::AddCommentByType(const Comment::Ptr& comment, bool historical) return; } + fields1->Set("unique_id", comment->GetName()); fields1->Set("comment_time", DbValue::FromTimestamp(entry_time)); /* same as entry_time */ fields1->Set("author_name", comment->GetAuthor()); fields1->Set("comment_data", comment->GetText()); @@ -487,6 +488,7 @@ void DbEvents::AddDowntimeByType(const Downtime::Ptr& downtime, bool historical) return; } + fields1->Set("unique_id", downtime->GetName()); fields1->Set("author_name", downtime->GetAuthor()); fields1->Set("comment_data", downtime->GetComment()); fields1->Set("triggered_by_id", Downtime::GetByName(downtime->GetTriggeredBy())); diff --git a/lib/db_ido_mysql/schema/mysql.sql b/lib/db_ido_mysql/schema/mysql.sql index 8b964c9b4..ea004edd4 100644 --- a/lib/db_ido_mysql/schema/mysql.sql +++ b/lib/db_ido_mysql/schema/mysql.sql @@ -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'; @@ -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'; @@ -411,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'; @@ -972,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'; diff --git a/lib/db_ido_mysql/schema/upgrade/2.4.0.sql b/lib/db_ido_mysql/schema/upgrade/2.4.0.sql index 3ff9c033f..a7bf0fcb0 100644 --- a/lib/db_ido_mysql/schema/upgrade/2.4.0.sql +++ b/lib/db_ido_mysql/schema/upgrade/2.4.0.sql @@ -58,6 +58,16 @@ ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token varchar(512) ch 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 -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql index 1ea554d21..8b9a8ce7f 100644 --- a/lib/db_ido_pgsql/schema/pgsql.sql +++ b/lib/db_ido_pgsql/schema/pgsql.sql @@ -108,6 +108,7 @@ CREATE TABLE icinga_commenthistory ( expiration_time timestamp with time zone default '1970-01-01 00:00:00+00', deletion_time timestamp with time zone default '1970-01-01 00:00:00+00', deletion_time_usec INTEGER default 0, + unique_id TEXT default NULL, CONSTRAINT PK_commenthistory_id PRIMARY KEY (commenthistory_id) , CONSTRAINT UQ_commenthistory UNIQUE (instance_id,object_id,comment_time,internal_comment_id) ); @@ -134,6 +135,7 @@ CREATE TABLE icinga_comments ( comment_source INTEGER default 0, expires INTEGER default 0, expiration_time timestamp with time zone default '1970-01-01 00:00:00+00', + unique_id TEXT default NULL, CONSTRAINT PK_comment_id PRIMARY KEY (comment_id) , CONSTRAINT UQ_comments UNIQUE (instance_id,object_id,comment_time,internal_comment_id) ) ; @@ -438,6 +440,7 @@ CREATE TABLE icinga_downtimehistory ( was_cancelled INTEGER default 0, is_in_effect INTEGER default 0, trigger_time timestamp with time zone default '1970-01-01 00:00:00+00', + unique_id TEXT default NULL, CONSTRAINT PK_downtimehistory_id PRIMARY KEY (downtimehistory_id) , CONSTRAINT UQ_downtimehistory UNIQUE (instance_id,object_id,entry_time,internal_downtime_id) ) ; @@ -999,6 +1002,7 @@ CREATE TABLE icinga_scheduleddowntime ( actual_start_time_usec INTEGER default 0, is_in_effect INTEGER default 0, trigger_time timestamp with time zone default '1970-01-01 00:00:00+00', + unique_id TEXT default NULL, CONSTRAINT PK_scheduleddowntime_id PRIMARY KEY (scheduleddowntime_id) , CONSTRAINT UQ_scheduleddowntime UNIQUE (instance_id,object_id,entry_time,internal_downtime_id) ) ; diff --git a/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql index 968652f9b..909869a50 100644 --- a/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql +++ b/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql @@ -154,18 +154,30 @@ CREATE TABLE icinga_zonestatus ( -- ----------------------------------------- -- #10392 original attributes -- ----------------------------------------- + ALTER TABLE icinga_servicestatus ADD COLUMN original_attributes TEXT default NULL; ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT default NULL; -- ----------------------------------------- -- #10436 deleted custom vars -- ----------------------------------------- + ALTER TABLE icinga_customvariables ADD COLUMN session_token TEXT default NULL; ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token TEXT 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 default NULL; +ALTER TABLE icinga_commenthistory ADD COLUMN unique_id TEXT default NULL; + +ALTER TABLE icinga_scheduleddowntime ADD COLUMN unique_id TEXT default NULL; +ALTER TABLE icinga_downtimehistory ADD COLUMN unique_id TEXT default NULL; + -- ----------------------------------------- -- update dbversion -- -----------------------------------------