mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
3d41105e1b
commit
9c7aade3d1
@ -19,6 +19,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;
|
||||
|
||||
@ -55,6 +58,7 @@ public class Upgrade228to229 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
dropKeysIfExist(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,4 +66,31 @@ public class Upgrade228to229 implements DbUpgrade {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,5 +5,5 @@
|
||||
ALTER TABLE `cloud`.`account` 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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user