From b92208c91c33f6ba274e90118afb3156aa22744a Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Tue, 19 Jul 2011 10:15:14 -0700 Subject: [PATCH] bug 10756: Removed constraints for the op_host_capacity table. op_host_capacity table is a table that is frequently updated and is only used in the background. There's no real reason for it to maintain data integrity with other tables. This change may introduce problems where data center, cluster, or pod is deleted and there are capacities entries left. However, this really should be in the application logic to do this deletion rather than relying on the database schema. Be sure to test these cases and make sure there are no data left over. --- setup/db/create-schema.sql | 3 --- setup/db/db/schema-228to229.sql | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 3787c584aa6..0a93a8e19b2 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1042,11 +1042,8 @@ CREATE TABLE `cloud`.`op_host_capacity` ( `capacity_type` int(1) unsigned NOT NULL, PRIMARY KEY (`id`), INDEX `i_op_host_capacity__host_type`(`host_id`, `capacity_type`), - CONSTRAINT `fk_op_host_capacity__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE, INDEX `i_op_host_capacity__pod_id`(`pod_id`), - CONSTRAINT `fk_op_host_capacity__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center` (`id`) ON DELETE CASCADE, INDEX `i_op_host_capacity__data_center_id`(`data_center_id`), - CONSTRAINT `fk_op_host_capacity__cluster_id` FOREIGN KEY `fk_op_host_capacity__cluster_id` (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE, INDEX `i_op_host_capacity__cluster_id`(`cluster_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/setup/db/db/schema-228to229.sql b/setup/db/db/schema-228to229.sql index 3a4468c89a7..086c91ae44e 100644 --- a/setup/db/db/schema-228to229.sql +++ b/setup/db/db/schema-228to229.sql @@ -7,3 +7,6 @@ ALTER TABLE `cloud`.`domain` ADD COLUMN `network_domain` varchar(255); ALTER TABLE `cloud`.`cluster` ADD CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`op_host_capacity` DROP FOREIGN KEY `fk_op_host_capacity__pod_id`; +ALTER TABLE `cloud`.`op_host_capacity` DROP FOREIGN KEY `fk_op_host_capacity__data_center_id`; +ALTER TABLE `cloud`.`op_host_capacity` DROP FOREIGN KEY `fk_op_host_capacity__cluster_id`; \ No newline at end of file