mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-21 13:03:10 +01:00
bug 10733: fixed/added incorrect/missing keys in 228 to 229 upgrade
status 10733: resolved fixed
This commit is contained in:
parent
0d84cde633
commit
f67c771410
@ -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,3 +5,5 @@
|
||||
ALTER TABLE `cloud`.`account` ADD COLUMN `network_domain` varchar(255);
|
||||
ALTER TABLE `cloud`.`domain` ADD COLUMN `network_domain` varchar(255);
|
||||
|
||||
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