[icinga-checkins] icinga.org: icinga-core/master: idoutils: fix upgradedb script typos & past changes #2682

git at icinga.org git at icinga.org
Fri Jun 15 17:21:58 CEST 2012


Module: icinga-core
Branch: master
Commit: 271eb06b3c4f0236d1b7c7da6955760a4724ba26
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=271eb06b3c4f0236d1b7c7da6955760a4724ba26

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Jun 13 14:00:26 2012 +0200

idoutils: fix upgradedb script typos & past changes #2682

fixes #2682

---

 Changelog                               |    1 +
 module/idoutils/db/scripts/upgradedb.in |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 0727766..340b678 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ FIXES
 * classic ui: Fixed status.cgi time out when displaying hostgroups in large environments #2617 - RB
 
 * idoutils: fix small compiler issues #2620 - TD/CF
+* idoutils: fix upgradedb script typos & past changes #2682 - MF
 
 * config: check_ido2db_procs.cfg should not depend on local-service template #2616 - MF
 
diff --git a/module/idoutils/db/scripts/upgradedb.in b/module/idoutils/db/scripts/upgradedb.in
index d131146..8096006 100755
--- a/module/idoutils/db/scripts/upgradedb.in
+++ b/module/idoutils/db/scripts/upgradedb.in
@@ -48,7 +48,7 @@ my $dbh = DBI->connect("DBI:mysql:database=$database;host=$hostname",
 eval { $dbh->do("SELECT * FROM icinga_dbversion LIMIT 1") };
 if ($@) {
 	print "*** Creating table icinga_dbversion",$/;
-	$dbh->do("CREATE TABLE icinga_dbversion (name VARCHAR(10) NOT NULL, version VARCHAR(10) NOT NULL);");
+	$dbh->do("CREATE TABLE IF NOT EXISTS icinga_dbversion (dbversion_id serial, name varchar(10) character set latin1  default '', version varchar(10) character set latin1  default '', create_time timestamp default '0000-00-00 00:00:00', modify_time timestamp default '0000-00-00 00:00:00', PRIMARY KEY (dbversion_id), UNIQUE KEY dbversion (name)) ENGINE=InnoDB;");
 };
 
 # Get current database version
@@ -61,7 +61,7 @@ $version = $dbh->selectrow_array("SELECT version FROM icinga_dbversion WHERE nam
 if ($version eq "") {
 	# Assume last legacy release (didn't have version table)
 	print "*** Assuming version $legacyversion of idoutils installed",$/;
-	$dbh->do("INSERT icinga_dbversion SET name='idoutils', version='$legacyversion';");
+	$dbh->do("INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '$legacyversion', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='$legacyversion', modify_time=NOW();");
 	$version = $legacyversion;
 };
 
@@ -74,7 +74,7 @@ if ($version eq $thisversion){
 
 
 # Read upgrade script in the directory containing this script
-my $file="../mysql/mysql-upgrade-$version.sql";
+my $file="../mysql/upgrade/mysql-upgrade-$version.sql";
 if (-e $file){
 	print "** DB upgrade required for $thisversion",$/;
 	print "     Using $file for upgrade...",$/;





More information about the icinga-checkins mailing list