diff --git a/server/src/com/cloud/upgrade/dao/Upgrade301to302.java b/server/src/com/cloud/upgrade/dao/Upgrade301to302.java index ec8d1ede290..c2ff70afc6e 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade301to302.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade301to302.java @@ -17,6 +17,9 @@ package com.cloud.upgrade.dao; */ import java.io.File; import java.sql.Connection; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import org.apache.log4j.Logger; @@ -51,8 +54,22 @@ public class Upgrade301to302 implements DbUpgrade { return new File[] { new File(script) }; } + private void dropKeysIfExists(Connection conn) { + HashMap> uniqueKeys = new HashMap>(); + List keys = new ArrayList(); + + keys.add("i_host__allocation_state"); + uniqueKeys.put("host", keys); + + s_logger.debug("Droping i_host__allocation_state key in host table"); + for (String tableName : uniqueKeys.keySet()) { + DbUpgradeUtils.dropKeysIfExist(conn, tableName, uniqueKeys.get(tableName), false); + } + } + @Override public void performDataMigration(Connection conn) { + dropKeysIfExists(conn); } @Override diff --git a/setup/db/db/schema-301to302.sql b/setup/db/db/schema-301to302.sql index e11160852dc..f51f3977054 100755 --- a/setup/db/db/schema-301to302.sql +++ b/setup/db/db/schema-301to302.sql @@ -21,7 +21,5 @@ DELETE FROM `cloud`.`configuration` WHERE name='secstorage.vm.ram.size'; INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'consoleproxy.service.offering', NULL, 'Service offering used by console proxy; if NULL - system offering will be used'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'secstorage.service.offering', NULL, 'Service offering used by secondary storage; if NULL - system offering will be used'); - -DROP INDEX `i_host__allocation_state` ON `cloud`.`host`; ALTER TABLE `cloud`.`domain_router` ADD CONSTRAINT `fk_domain_router__element_id` FOREIGN KEY `fk_domain_router__element_id`(`element_id`) REFERENCES `virtual_router_providers`(`id`);