From 34514d9ab5d14a2f19f64371b81441e8cebaf9ac Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Thu, 23 Aug 2012 16:10:34 -0700 Subject: [PATCH] CS-16146 2.2.14 to 3.0.5 : Upgrade fails for Production DB Reviewed-by: Anthony Xu Changes: - host_details should not contain duplicates - CloudStack always removes entire set of details and add new. - Maybe 2.2.14 had some bug causing the duplicate. - Added IGNORE to the ALTER sql to take care of duplicates in host_details. --- server/src/com/cloud/upgrade/dao/Upgrade304to305.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade304to305.java b/server/src/com/cloud/upgrade/dao/Upgrade304to305.java index 8a496964af0..94a47767d25 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade304to305.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade304to305.java @@ -238,7 +238,7 @@ public class Upgrade304to305 extends Upgrade30xBase implements DbUpgrade { s_logger.debug("Unique key already exists on host_details - not adding new one"); }else{ //add the key - PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD CONSTRAINT UNIQUE KEY `uk_host_id_name` (`host_id`, `name`)"); + PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD CONSTRAINT UNIQUE KEY `uk_host_id_name` (`host_id`, `name`)"); pstmtUpdate.executeUpdate(); s_logger.debug("Unique key did not exist on host_details - added new one"); pstmtUpdate.close();