Cloudstack-4100 preserve data in iso_id column while upgrading from 3.0.7 to 4.2

Conflicts:
	engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
This commit is contained in:
Bharat Kumar 2013-08-07 17:54:34 +05:30 committed by Kishan Kavala
parent 3de6cdb4f9
commit e55844c364
2 changed files with 21 additions and 1 deletions

View File

@ -104,6 +104,7 @@ public class Upgrade410to420 implements DbUpgrade {
fixNiciraKeys(conn);
fixRouterKeys(conn);
encryptSite2SitePSK(conn);
migrateDatafromIsoIdInVolumesTable(conn);
}
private void fixBaremetalForeignKeys(Connection conn) {
@ -2115,4 +2116,23 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void migrateDatafromIsoIdInVolumesTable(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement("SELECT iso_id1 From `cloud`.`volumes`");
rs = pstmt.executeQuery();
if (rs.next()) {
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`volumes` DROP COLUMN `iso_id`");
pstmt.executeUpdate();
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`volumes` CHANGE COLUMN `iso_id1` `iso_id` bigint(20) unsigned COMMENT 'The id of the iso from which the volume was created'");
pstmt.executeUpdate();
}
}catch (SQLException e) {
//implies iso_id1 is not present, so do nothing.
}
}
}

View File

@ -1572,4 +1572,4 @@ ALTER TABLE `cloud_usage`.`usage_storage` CHANGE COLUMN `virtual_size` `virtual_
ALTER TABLE `cloud_usage`.`cloud_usage` CHANGE COLUMN `virtual_size` `virtual_size1` bigint unsigned;
ALTER TABLE `cloud`.`network_offerings` CHANGE COLUMN `concurrent_connections` `concurrent_connections1` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)';
ALTER TABLE `cloud`.`volumes` DROP COLUMN `iso_id`;
ALTER TABLE `cloud`.`volumes` CHANGE COLUMN `iso_id` `iso_id1` bigint(20) unsigned COMMENT 'The id of the iso from which the volume was created';