From 49650f3eb62c147b71ea2fd5c796e731a692aa9a Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 2 Jun 2011 09:51:17 -0700 Subject: [PATCH] host_address in storage_pool should not have gotten the change to char(40) --- .../com/cloud/upgrade/DatabaseUpgradeChecker.java | 15 +++++++++++---- setup/db/db/schema-222to224.sql | 1 - setup/db/db/schema-224to225.sql | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index 6f7aea20ccd..226aae0cfc4 100644 --- a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -73,10 +73,9 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { _upgradeMap.put("2.2.4", new DbUpgrade[] { new Upgrade224to225() }); } - protected void runScript(File file) { + protected void runScript(Connection conn, File file) { try { FileReader reader = new FileReader(file); - Connection conn = Transaction.getStandaloneConnection(); ScriptRunner runner = new ScriptRunner(conn, false, true); runner.runScript(reader); } catch (FileNotFoundException e) { @@ -140,7 +139,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { File[] scripts = upgrade.getPrepareScripts(); if (scripts != null) { for (File script : scripts) { - runScript(script); + runScript(conn, script); } } @@ -201,11 +200,19 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { + upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); txn.start(); + + Connection conn; + try { + conn = txn.getConnection(); + } catch (SQLException e) { + s_logger.error("Unable to cleanup the database", e); + throw new CloudRuntimeException("Unable to cleanup the database", e); + } File[] scripts = upgrade.getCleanupScripts(); if (scripts != null) { for (File script : scripts) { - runScript(script); + runScript(conn, script); s_logger.debug("Cleanup script " + script.getAbsolutePath() + " is executed successfully"); } } diff --git a/setup/db/db/schema-222to224.sql b/setup/db/db/schema-222to224.sql index f9b0f7246c0..b34e6cb1e53 100644 --- a/setup/db/db/schema-222to224.sql +++ b/setup/db/db/schema-222to224.sql @@ -43,7 +43,6 @@ ALTER TABLE `cloud`.`domain_router` MODIFY `guest_ip_address` char(40); ALTER TABLE `cloud`.`console_proxy` MODIFY `public_ip_address` char(40) UNIQUE; ALTER TABLE `cloud`.`secondary_storage_vm` MODIFY `public_ip_address` char(40) UNIQUE; ALTER TABLE `cloud`.`remote_access_vpn` MODIFY `local_ip` char(40) NOT NULL; -ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` char(40) NOT NULL; ALTER TABLE `cloud`.`user_ip_address` MODIFY `public_ip_address` char(40) NOT NULL; #Commented out these lines because they have to be done inside java.; diff --git a/setup/db/db/schema-224to225.sql b/setup/db/db/schema-224to225.sql index 1bd88bad91c..e1fe3c41450 100644 --- a/setup/db/db/schema-224to225.sql +++ b/setup/db/db/schema-224to225.sql @@ -3,6 +3,7 @@ --; ALTER TABLE `cloud`.`security_group` add UNIQUE KEY (`name`, `account_id`); +ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` varchar(255) NOT NULL; CREATE TABLE IF NOT EXISTS `cloud`.`ovs_tunnel`( `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,