CLOUDSTACK-7210: removed duplicated foreign key from async_job_join_map table

This commit is contained in:
Alena Prokharchyk 2014-08-01 10:14:51 -07:00
parent 93c64cd7f2
commit 685a58a843

View File

@ -60,6 +60,7 @@ public class Upgrade441to450 implements DbUpgrade {
@Override
public void performDataMigration(Connection conn) {
dropInvalidKeyFromStoragePoolTable(conn);
dropDuplicatedForeignKeyFromAsyncJobTable(conn);
}
@ -80,9 +81,22 @@ public class Upgrade441to450 implements DbUpgrade {
keys.add("id_2");
uniqueKeys.put("storage_pool", keys);
s_logger.debug("Droping id_2 key from storage_pool table");
s_logger.debug("Dropping id_2 key from storage_pool table");
for (Map.Entry<String, List<String>> entry: uniqueKeys.entrySet()) {
DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(), entry.getValue(), false);
}
}
private void dropDuplicatedForeignKeyFromAsyncJobTable(Connection conn) {
HashMap<String, List<String>> foreignKeys = new HashMap<String, List<String>>();
List<String> keys = new ArrayList<String>();
keys.add("fk_async_job_join_map__join_job_id");
foreignKeys.put("async_job_join_map", keys);
s_logger.debug("Dropping fk_async_job_join_map__join_job_id key from async_job_join_map table");
for (Map.Entry<String, List<String>> entry: foreignKeys.entrySet()) {
DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(), entry.getValue(), true);
}
}
}