bug 10733: fixed/added incorrect/missing keys in 228 to 229 upgrade

status 10733: resolved fixed

Conflicts:

	setup/db/db/schema-228to229.sql
This commit is contained in:
alena 2011-07-15 15:10:11 -07:00
parent 3d41105e1b
commit 9c7aade3d1
2 changed files with 32 additions and 1 deletions

View File

@ -19,6 +19,9 @@ package com.cloud.upgrade.dao;
import java.io.File; import java.io.File;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -55,6 +58,7 @@ public class Upgrade228to229 implements DbUpgrade {
@Override @Override
public void performDataMigration(Connection conn) { public void performDataMigration(Connection conn) {
dropKeysIfExist(conn);
} }
@Override @Override
@ -62,4 +66,31 @@ public class Upgrade228to229 implements DbUpgrade {
return null; return null;
} }
private void dropKeysIfExist(Connection conn) {
HashMap<String, List<String>> indexes = new HashMap<String, List<String>>();
HashMap<String, List<String>> foreignKeys = new HashMap<String, List<String>>();
//indexes to drop
List<String> keys = new ArrayList<String>();
keys.add("name");
indexes.put("network_offerings", keys);
//foreign keys to drop - this key would be re-added later
keys = new ArrayList<String>();
keys.add("fk_cluster__data_center_id");
foreignKeys.put("cluster", keys);
// drop all foreign keys first
s_logger.debug("Dropping keys that don't exist in 2.2.6 version of the DB...");
for (String tableName : foreignKeys.keySet()) {
DbUpgradeUtils.dropKeysIfExist(conn, tableName, foreignKeys.get(tableName), true);
}
// drop indexes now
for (String tableName : indexes.keySet()) {
DbUpgradeUtils.dropKeysIfExist(conn, tableName, indexes.get(tableName), false);
}
}
} }

View File

@ -5,5 +5,5 @@
ALTER TABLE `cloud`.`account` ADD COLUMN `network_domain` varchar(255); ALTER TABLE `cloud`.`account` ADD COLUMN `network_domain` varchar(255);
ALTER TABLE `cloud`.`domain` ADD COLUMN `network_domain` varchar(255); ALTER TABLE `cloud`.`domain` ADD COLUMN `network_domain` varchar(255);
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'network.dns.basiczone.updates', 'all', 'This parameter can take 2 values: all (default) and pod. It defines if DHCP/DNS requests have to be send to all dhcp servers in cloudstack, or only to the one in the same pod'); ALTER TABLE `cloud`.`cluster` ADD CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE;