bug 13474: fixed 1) 2) and 4)

reviewed-by: Frank
This commit is contained in:
Alena Prokharchyk 2012-02-06 17:40:46 -08:00
parent 72cf29c9ce
commit 257099b6a4
3 changed files with 36 additions and 3 deletions

View File

@ -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<String>();
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<String>();
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);
}
}
}

View File

@ -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`);

View File

@ -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';
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';