From 257099b6a4251dac2efb9eae5f05e88db3fd73e2 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 6 Feb 2012 17:40:46 -0800 Subject: [PATCH] bug 13474: fixed 1) 2) and 4) reviewed-by: Frank --- .../cloud/upgrade/dao/Upgrade2213to2214.java | 32 ++++++++++++++++++- setup/db/create-index-fk.sql | 2 +- setup/db/db/schema-2213to2214.sql | 5 ++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java b/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java index 74fd14545a6..ddd5d12dec7 100755 --- a/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2213to2214.java @@ -166,6 +166,36 @@ public class Upgrade2213to2214 implements DbUpgrade { } catch (SQLException e) { throw new CloudRuntimeException("Unable to insert index for removed column in async_job", e); } - + + //Drop storage pool details keys (if exists) and insert one with correct name + keys = new ArrayList(); + keys.add("fk_storage_pool__pool_id"); + keys.add("fk_storage_pool_details__pool_id"); + DbUpgradeUtils.dropKeysIfExist(conn, "cloud.storage_pool_details", keys, true); + DbUpgradeUtils.dropKeysIfExist(conn, "cloud.storage_pool_details", keys, false); + try { + PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`storage_pool_details` ADD CONSTRAINT `fk_storage_pool_details__pool_id` FOREIGN KEY `fk_storage_pool_details__pool_id`(`pool_id`) REFERENCES `storage_pool`(`id`) ON DELETE CASCADE"); + pstmt.executeUpdate(); + pstmt.close(); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to insert foreign key in storage_pool_details ", e); + } + + //Drop securityGroup keys (if exists) and insert one with correct name + keys = new ArrayList(); + keys.add("fk_security_group___account_id"); + keys.add("fk_security_group__account_id"); + DbUpgradeUtils.dropKeysIfExist(conn, "cloud.security_group", keys, true); + DbUpgradeUtils.dropKeysIfExist(conn, "cloud.security_group", keys, false); + try { + PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`security_group` ADD CONSTRAINT `fk_security_group__account_id` FOREIGN KEY `fk_security_group__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE"); + pstmt.executeUpdate(); + pstmt.close(); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to insert foreign key in security_group table ", e); + } + + + } } diff --git a/setup/db/create-index-fk.sql b/setup/db/create-index-fk.sql index 61272d350f6..8d2f9dda101 100755 --- a/setup/db/create-index-fk.sql +++ b/setup/db/create-index-fk.sql @@ -56,7 +56,7 @@ ALTER TABLE `cloud`.`launch_permission` ADD INDEX `i_launch_permission_template_ ALTER TABLE `cloud`.`guest_os` ADD CONSTRAINT `fk_guest_os__category_id` FOREIGN KEY `fk_guest_os__category_id` (`category_id`) REFERENCES `guest_os_category` (`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`security_group` ADD CONSTRAINT `fk_security_group___account_id` FOREIGN KEY `fk_security_group__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`security_group` ADD CONSTRAINT `fk_security_group__account_id` FOREIGN KEY `fk_security_group__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`security_group` ADD CONSTRAINT `fk_security_group__domain_id` FOREIGN KEY `fk_security_group__domain_id` (`domain_id`) REFERENCES `domain` (`id`); ALTER TABLE `cloud`.`security_group` ADD INDEX `i_security_group_name`(`name`); diff --git a/setup/db/db/schema-2213to2214.sql b/setup/db/db/schema-2213to2214.sql index 196d2273aca..4c5bf7993d5 100644 --- a/setup/db/db/schema-2213to2214.sql +++ b/setup/db/db/schema-2213to2214.sql @@ -54,4 +54,7 @@ CREATE TABLE `cloud`.`vm_template_details` ( ALTER TABLE `cloud`.`domain_router` MODIFY `is_redundant_router` int(1) unsigned NOT NULL COMMENT 'if in redundant router mode'; ALTER TABLE `cloud`.`domain_router` MODIFY `is_priority_bumpup` int(1) unsigned NOT NULL COMMENT 'if the priority has been bumped up'; ALTER TABLE `cloud`.`domain_router` MODIFY `redundant_state` varchar(64) NOT NULL COMMENT 'the state of redundant virtual router'; -ALTER TABLE `cloud`.`domain_router` MODIFY `stop_pending` int(1) unsigned NOT NULL COMMENT 'if this router would be stopped after we can connect to it'; \ No newline at end of file +ALTER TABLE `cloud`.`domain_router` MODIFY `stop_pending` int(1) unsigned NOT NULL COMMENT 'if this router would be stopped after we can connect to it'; + + +ALTER TABLE `cloud`.`storage_pool_details` MODIFY `limit_cpu_use` tinyint(1) unsigned NOT NULL default '0' COMMENT 'Limit the CPU usage to service offering'; \ No newline at end of file