diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java index b5da56bd7be..3f3f3bfed95 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -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. + } + + } } diff --git a/setup/db/db/schema-307to410.sql b/setup/db/db/schema-307to410.sql index af296abbe25..d9815b6163e 100644 --- a/setup/db/db/schema-307to410.sql +++ b/setup/db/db/schema-307to410.sql @@ -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`; \ No newline at end of file +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'; \ No newline at end of file