From aec6b4af48c407a8e055656f0183f8d6eae1c9e2 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Thu, 23 Aug 2012 17:52:04 -0700 Subject: [PATCH] [ASFCS40]Upgrade to 4.0: host_details unique key addition needs IGNORE keyword to correct the duplicates --- server/src/com/cloud/upgrade/dao/Upgrade302to40.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade302to40.java b/server/src/com/cloud/upgrade/dao/Upgrade302to40.java index 198dafdbf11..0a836e92620 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade302to40.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade302to40.java @@ -517,7 +517,7 @@ public class Upgrade302to40 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();