CS-14429 Cloud db schema differences between fresh installed 3.0.2 & upgraded 3.0.2

do check befor droping index i_host__allocation_state`(`allocation_state`)
This commit is contained in:
frank 2012-04-11 17:21:01 -07:00
parent 52e334cefc
commit 7744abcacb
2 changed files with 17 additions and 2 deletions

View File

@ -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<String, List<String>> uniqueKeys = new HashMap<String, List<String>>();
List<String> keys = new ArrayList<String>();
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

View File

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