From 3ae5986b87852c094f2412b22345bc4d10cb3ade Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Fri, 21 Dec 2012 15:27:00 +0530 Subject: [PATCH] Update DB version during DB deploy 1. Modified create-schema.sql to add version as 4.1.0 instead of 4.0.0 2. Removed schema-40to41.sql amd moved the content to schema-40to410.sql 3. Added to schema-40to410.sql Upgrade40to41.java Conflicts: server/src/com/cloud/upgrade/dao/Upgrade40to41.java setup/db/create-schema.sql setup/db/db/schema-40to41.sql setup/db/db/schema-40to410.sql Signed-off-by: Min Chen --- .../com/cloud/upgrade/dao/Upgrade40to41.java | 6 +-- setup/db/create-schema.sql | 8 +-- .../{schema-40to41.sql => schema-40to410.sql} | 50 +++++++++++++++++-- 3 files changed, 55 insertions(+), 9 deletions(-) rename setup/db/db/{schema-40to41.sql => schema-40to410.sql} (86%) mode change 100755 => 100644 diff --git a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java index a3fb2ea1091..3ba0ed8a737 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java @@ -27,7 +27,7 @@ import com.cloud.utils.script.Script; * @author htrippaers * */ -public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade40to41 implements DbUpgrade { /** * @@ -65,9 +65,9 @@ public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { */ @Override public File[] getPrepareScripts() { - String script = Script.findScript("", "db/schema-40to41.sql"); + String script = Script.findScript("", "db/schema-40to410.sql"); if (script == null) { - throw new CloudRuntimeException("Unable to find db/schema-40to41.sql"); + throw new CloudRuntimeException("Unable to find db/schema-40to410.sql"); } return new File[] { new File(script) }; diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index c01a5cdccac..365ff968740 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -164,7 +164,8 @@ CREATE TABLE `cloud`.`version` ( INDEX `i_version__version`(`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `version` (`version`, `updated`, `step`) VALUES('@VERSION@', now(), 'Complete'); + +INSERT INTO `version` (`version`, `updated`, `step`) VALUES('4.1.0', now(), 'Complete'); CREATE TABLE `cloud`.`op_it_work` ( `id` char(40) COMMENT 'reservation id', @@ -1115,6 +1116,7 @@ CREATE TABLE `cloud`.`upload` ( `id` bigint unsigned NOT NULL auto_increment, `host_id` bigint unsigned NOT NULL, `type_id` bigint unsigned NOT NULL, + `uuid` varchar(40), `type` varchar(255), `mode` varchar(255), `created` DATETIME NOT NULL, @@ -1337,7 +1339,7 @@ CREATE TABLE `cloud`.`async_job` ( `session_key` varchar(64) COMMENT 'all async-job manage to apply session based security enforcement', `instance_type` varchar(64) COMMENT 'instance_type and instance_id work together to allow attaching an instance object to a job', `instance_id` bigint unsigned, - `job_cmd` varchar(64) NOT NULL COMMENT 'command name', + `job_cmd` varchar(255) NOT NULL COMMENT 'command name', `job_cmd_originator` varchar(64) COMMENT 'command originator', `job_cmd_info` text COMMENT 'command parameter info', `job_cmd_ver` int(1) COMMENT 'command version', @@ -2511,7 +2513,7 @@ INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'net SET foreign_key_checks = 1; -ALTER TABLE upload ADD uuid VARCHAR(40); + --- DB views for list api --- DROP VIEW IF EXISTS `cloud`.`user_vm_view`; diff --git a/setup/db/db/schema-40to41.sql b/setup/db/db/schema-40to410.sql old mode 100755 new mode 100644 similarity index 86% rename from setup/db/db/schema-40to41.sql rename to setup/db/db/schema-40to410.sql index d94aed87302..2ebea02dade --- a/setup/db/db/schema-40to41.sql +++ b/setup/db/db/schema-40to410.sql @@ -5,9 +5,9 @@ -- to you under the Apache License, Version 2.0 (the -- "License"); you may not use this file except in compliance -- with the License. You may obtain a copy of the License at --- +-- -- http://www.apache.org/licenses/LICENSE-2.0 --- +-- -- Unless required by applicable law or agreed to in writing, -- software distributed under the License is distributed on an -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -15,9 +15,53 @@ -- specific language governing permissions and limitations -- under the License. --- Schema upgrade from 4.0 to 4.1; +--; +-- Schema upgrade from 4.0.0 to 4.1.0; +--; + +CREATE TABLE `cloud`.`s3` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `uuid` varchar(40), + `access_key` varchar(20) NOT NULL COMMENT ' The S3 access key', + `secret_key` varchar(40) NOT NULL COMMENT ' The S3 secret key', + `end_point` varchar(1024) COMMENT ' The S3 host', + `bucket` varchar(63) NOT NULL COMMENT ' The S3 host', + `https` tinyint unsigned DEFAULT NULL COMMENT ' Flag indicating whether or not to connect over HTTPS', + `connection_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) when initially establishing a connection before giving up and timing out.', + `max_error_retry` integer COMMENT ' The maximum number of retry attempts for failed retryable requests (ex: 5xx error responses from services).', + `socket_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) for data to be transfered over an established, open connection before the connection times out and is closed.', + `created` datetime COMMENT 'date the s3 first signed on', + PRIMARY KEY (`id`), + CONSTRAINT `uc_s3__uuid` UNIQUE (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`template_s3_ref` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `s3_id` bigint unsigned NOT NULL COMMENT ' Associated S3 instance id', + `template_id` bigint unsigned NOT NULL COMMENT ' Associated template id', + `created` DATETIME NOT NULL COMMENT ' The creation timestamp', + `size` bigint unsigned COMMENT ' The size of the object', + `physical_size` bigint unsigned DEFAULT 0 COMMENT ' The physical size of the object', + PRIMARY KEY (`id`), + CONSTRAINT `uc_template_s3_ref__template_id` UNIQUE (`template_id`), + CONSTRAINT `fk_template_s3_ref__s3_id` FOREIGN KEY `fk_template_s3_ref__s3_id` (`s3_id`) REFERENCES `s3` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_template_s3_ref__template_id` FOREIGN KEY `fk_template_s3_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`), + INDEX `i_template_s3_ref__swift_id`(`s3_id`), + INDEX `i_template_s3_ref__template_id`(`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.enable', 'false', 'enable s3'); + +ALTER TABLE `cloud`.`snapshots` ADD COLUMN `s3_id` bigint unsigned COMMENT 'S3 to which this snapshot will be stored'; + +ALTER TABLE `cloud`.`snapshots` ADD CONSTRAINT `fk_snapshots__s3_id` FOREIGN KEY `fk_snapshots__s3_id` (`s3_id`) REFERENCES `s3` (`id`); + +ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`; + +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network','DEFAULT','NetworkManager','network.dhcp.nondefaultnetwork.setgateway.guestos','Windows','The guest OS\'s name start with this fields would result in DHCP server response gateway information even when the network it\'s on is not default network. Names are separated by comma.'); ALTER TABLE upload ADD uuid VARCHAR(40); +ALTER TABLE async_job modify job_cmd VARCHAR(255); -- populate uuid column with db id if uuid is null UPDATE `cloud`.`account` set uuid=id WHERE uuid is NULL;