From b46a53579f692cbf1c020e8b5d4cb9b6cdbddcba Mon Sep 17 00:00:00 2001 From: prachi Date: Wed, 5 Jan 2011 13:53:57 -0800 Subject: [PATCH] DB schema changes that will be needed for the host tags feature. This commit does not include any code changes for the feature. --- setup/db/create-index-fk.sql | 1 + setup/db/create-schema.sql | 9 +++++++++ setup/db/schema-22beta3to22beta4.sql | 10 ++++++++++ 3 files changed, 20 insertions(+) create mode 100644 setup/db/schema-22beta3to22beta4.sql diff --git a/setup/db/create-index-fk.sql b/setup/db/create-index-fk.sql index accdd50093e..033ec9f2343 100755 --- a/setup/db/create-index-fk.sql +++ b/setup/db/create-index-fk.sql @@ -50,6 +50,7 @@ ALTER TABLE `cloud`.`host` ADD CONSTRAINT `fk_host__cluster_id` FOREIGN KEY `fk_ ALTER TABLE `cloud`.`op_host` ADD CONSTRAINT `fk_op_host__id` FOREIGN KEY `fk_op_host__id`(`id`) REFERENCES `host`(`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`host_details` ADD CONSTRAINT `fk_host_details__host_id` FOREIGN KEY `fk_host_details__host_id`(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`host_tags` ADD CONSTRAINT `fk_host_tags__host_id` FOREIGN KEY `fk_host_tags__host_id`(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`storage_pool` ADD CONSTRAINT `fk_storage_pool__pod_id` FOREIGN KEY `fk_storage_pool__pod_id` (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`storage_pool` ADD INDEX `i_storage_pool__pod_id`(`pod_id`); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index aaebc1d804b..c310221e626 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -93,6 +93,7 @@ DROP TABLE IF EXISTS `cloud`.`port_forwarding_rules`; DROP TABLE IF EXISTS `cloud`.`firewall_rules`; DROP TABLE IF EXISTS `cloud`.`ssh_keypairs`; DROP TABLE IF EXISTS `cloud`.`usage_event`; +DROP TABLE IF EXISTS `cloud`.`host_tags`; CREATE TABLE `cloud`.`op_it_work` ( `id` char(40) COMMENT 'id', @@ -614,6 +615,13 @@ CREATE TABLE `cloud`.`mshost` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `cloud`.`host_tags` ( + `id` bigint unsigned NOT NULL auto_increment, + `host_id` bigint unsigned NOT NULL COMMENT 'host id', + `tag` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `cloud`.`user` ( `id` bigint unsigned NOT NULL auto_increment, `username` varchar(255) NOT NULL, @@ -1036,6 +1044,7 @@ CREATE TABLE `cloud`.`service_offering` ( `mc_rate` smallint unsigned default 10 COMMENT 'mcast rate throttle mbits/s', `ha_enabled` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Enable HA', `guest_ip_type` varchar(255) NOT NULL DEFAULT 'Virtualized' COMMENT 'Type of guest network -- direct or virtualized', + `host_tag` varchar(255) COMMENT 'host tag specified by the service_offering', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/setup/db/schema-22beta3to22beta4.sql b/setup/db/schema-22beta3to22beta4.sql new file mode 100644 index 00000000000..37a93f58b34 --- /dev/null +++ b/setup/db/schema-22beta3to22beta4.sql @@ -0,0 +1,10 @@ +CREATE TABLE `cloud`.`host_tags` ( + `id` bigint unsigned NOT NULL auto_increment, + `host_id` bigint unsigned NOT NULL COMMENT 'host id', + `tag` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `cloud`.`host_tags` ADD CONSTRAINT `fk_host_tags__host_id` FOREIGN KEY `fk_host_tags__host_id`(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE; + +ALTER TABLE `cloud`.`service_offering` ADD COLUMN `host_tag` varchar(255); \ No newline at end of file