mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
[ASFCS40]304 -> 305 DB upgrade merge to 302-> 4.0
This commit is contained in:
parent
511e3cb235
commit
0b31a0af62
@ -64,7 +64,7 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
|
||||
public void performDataMigration(Connection conn) {
|
||||
correctVRProviders(conn);
|
||||
correctMultiplePhysicaNetworkSetups(conn);
|
||||
|
||||
addHostDetailsUniqueKey(conn);
|
||||
addVpcProvider(conn);
|
||||
updateRouterNetworkRef(conn);
|
||||
fixForeignKeys(conn);
|
||||
@ -506,6 +506,37 @@ public class Upgrade302to40 extends Upgrade30xBase implements DbUpgrade {
|
||||
}
|
||||
}
|
||||
|
||||
private void addHostDetailsUniqueKey(Connection conn) {
|
||||
s_logger.debug("Checking if host_details unique key exists, if not we will add it");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` WHERE KEY_NAME = 'uk_host_id_name'");
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
s_logger.debug("Unique key already exists on host_details - not adding new one");
|
||||
}else{
|
||||
//add the key
|
||||
PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER TABLE `cloud`.`host_details` ADD CONSTRAINT UNIQUE KEY `uk_host_id_name` (`host_id`, `name`)");
|
||||
pstmtUpdate.executeUpdate();
|
||||
s_logger.debug("Unique key did not exist on host_details - added new one");
|
||||
pstmtUpdate.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Failed to check/update the host_details unique key ", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addVpcProvider(Connection conn){
|
||||
//Encrypt config params and change category to Hidden
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user