[ASFCS40]Upgrade to 4.0: host_details unique key addition needs IGNORE keyword to correct the duplicates

This commit is contained in:
Prachi Damle 2012-08-23 17:52:04 -07:00
parent e4c51e92ef
commit aec6b4af48

View File

@ -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();