From e7f6ffbd43afb4e1fb6ede49ddd562365a5496e5 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Thu, 2 Feb 2012 19:20:43 +0530 Subject: [PATCH] Bug 13423: Upgrade 2213 to 2214 add the snapshot index since it was introduced for 2214. Reviewed-By: Kishan --- .../src/com/cloud/upgrade/dao/Upgrade2213to2214.java | 12 ++++++++++++ setup/db/db/schema-2213to2214.sql | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) 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,