diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java b/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java index d5068aacf15..6f7d69b2283 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java @@ -93,6 +93,18 @@ public class Upgrade2213to2214 implements DbUpgrade { throw new CloudRuntimeException("Unable to execute cloud_usage usage_event table update", e); } + //Drop i_snapshots__removed key (if exists) and re-add it again + keys = new ArrayList(); + keys.add("i_snapshots__removed"); + DbUpgradeUtils.dropKeysIfExist(conn, "snapshots.removed", keys, false); + try { + PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`snapshots` ADD INDEX `i_snapshots__removed`(`removed`)"); + pstmt.executeUpdate(); + pstmt.close(); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to insert index for removed column in snapshots", e); + } + //Drop netapp_volume primary key and add it again DbUpgradeUtils.dropPrimaryKeyIfExists(conn, "cloud.netapp_volume"); try { diff --git a/setup/db/db/schema-2213to2214.sql b/setup/db/db/schema-2213to2214.sql index d964a6828ba..92b63ba7639 100644 --- a/setup/db/db/schema-2213to2214.sql +++ b/setup/db/db/schema-2213to2214.sql @@ -3,8 +3,7 @@ --; ALTER TABLE `cloud`.`vm_template` MODIFY `extractable` int(1) unsigned NOT NULL default 0 COMMENT 'Is this template extractable'; -ALTER TABLE `cloud`.`snapshots` ADD INDEX `i_snapshots__removed`(`removed`); -INSERT INTO configuration (category, instance, component, name, value, description) VALUES ('Advanced', 'DEFAULT', 'management-server', 'external.network.stats.interval', '300', 'Interval (in seconds) to report external network statistics.'); +INSERT IGNORE INTO `cloud`.`configuration` (category, instance, component, name, value, description) VALUES ('Advanced', 'DEFAULT', 'management-server', 'external.network.stats.interval', '300', 'Interval (in seconds) to report external network statistics.'); CREATE TABLE `cloud`.`mshost_peer` ( `id` bigint unsigned NOT NULL auto_increment,