From 8acc85ca5371d8fb3c66ac4083633849422f5654 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 --- .../com/cloud/upgrade/dao/Upgrade40to41.java | 10 ++++++-- setup/db/create-schema.sql | 2 +- setup/db/db/schema-40to41.sql | 25 ------------------- setup/db/db/schema-40to410.sql | 4 +++ 4 files changed, 13 insertions(+), 28 deletions(-) delete mode 100644 setup/db/db/schema-40to41.sql diff --git a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java index 393aefd744c..cfb783bb0fb 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java @@ -18,6 +18,7 @@ package com.cloud.upgrade.dao; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; import java.io.File; import java.sql.Connection; @@ -29,7 +30,7 @@ import java.sql.SQLException; * @author htrippaers * */ -public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { +public class Upgrade40to41 implements DbUpgrade { /** * @@ -67,7 +68,12 @@ public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { */ @Override public File[] getPrepareScripts() { - return new File[0]; + String script = Script.findScript("", "db/schema-40to410.sql"); + if (script == null) { + throw new CloudRuntimeException("Unable to find db/schema-40to410.sql"); + } + + return new File[] { new File(script) }; } /* (non-Javadoc) diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 8010e3b88c5..1b6ee5df112 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -166,7 +166,7 @@ CREATE TABLE `cloud`.`version` ( INDEX `i_version__version`(`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `version` (`version`, `updated`, `step`) VALUES('4.0.0.2012-09-12T14:47:37Z', 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', diff --git a/setup/db/db/schema-40to41.sql b/setup/db/db/schema-40to41.sql deleted file mode 100644 index 61cb4a22b39..00000000000 --- a/setup/db/db/schema-40to41.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- 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 --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - ---; --- Schema upgrade from 4.0 to 4.1.0; ---; - - -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.'); diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index b0301d72538..73289bca35b 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -56,3 +56,7 @@ ALTER TABLE `cloud`.`snapshots` ADD COLUMN `s3_id` bigint unsigned COMMENT 'S3 t 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.'); +