Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1454F11879 for ; Tue, 3 Jun 2014 08:05:26 +0000 (UTC) Received: (qmail 70780 invoked by uid 500); 3 Jun 2014 08:05:25 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 70739 invoked by uid 500); 3 Jun 2014 08:05:25 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 70631 invoked by uid 99); 3 Jun 2014 08:05:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jun 2014 08:05:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4A46892CAAA; Tue, 3 Jun 2014 08:05:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dahn@apache.org To: commits@cloudstack.apache.org Date: Tue, 03 Jun 2014 08:05:26 -0000 Message-Id: In-Reply-To: <24692bbe662d41df84d8374f9ee1b610@git.apache.org> References: <24692bbe662d41df84d8374f9ee1b610@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: updated refs/heads/4.4 to 9fd0655 CLOUDSTACK-6599: Add the column in Java upgrade path since 4.2 already has the extract template/volume columns Conflicts: engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9fd0655a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9fd0655a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9fd0655a Branch: refs/heads/4.4 Commit: 9fd0655adb602515022809e3fddaa1f3890f5dce Parents: 9286417 Author: Nitin Mehta Authored: Fri May 30 14:53:42 2014 -0700 Committer: Daan Hoogland Committed: Tue Jun 3 10:04:52 2014 +0200 ---------------------------------------------------------------------- .../com/cloud/upgrade/dao/Upgrade430to440.java | 30 ++++++++++++++++++++ setup/db/db/schema-430to440.sql | 4 --- 2 files changed, 30 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9fd0655a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java index 12be30e..8478f83 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java @@ -62,9 +62,39 @@ public class Upgrade430to440 implements DbUpgrade { public void performDataMigration(Connection conn) { secondaryIpsAccountAndDomainIdsUpdate(conn); moveCidrsToTheirOwnTable(conn); + addExtractTemplateAndVolumeColumns(conn); updateVlanUris(conn); } + private void addExtractTemplateAndVolumeColumns(Connection conn) { + PreparedStatement pstmt = null; + ResultSet rs = null; + + try { + + // Add download_url_created, download_url to template_store_ref + pstmt = conn.prepareStatement("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'cloud' AND TABLE_NAME = 'template_store_ref' AND COLUMN_NAME = 'download_url_created'"); + rs = pstmt.executeQuery(); + if (!rs.next()) { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`template_store_ref` ADD COLUMN `download_url_created` datetime"); + pstmt.executeUpdate(); + + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`template_store_ref` ADD COLUMN `download_url` varchar(255)"); + pstmt.executeUpdate(); + } + + // Add download_url_created to volume_store_ref - note download_url already exists + pstmt = conn.prepareStatement("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'cloud' AND TABLE_NAME = 'volume_store_ref' AND COLUMN_NAME = 'download_url_created'"); + rs = pstmt.executeQuery(); + if (!rs.next()) { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`volume_store_ref` ADD COLUMN `download_url_created` datetime"); + pstmt.executeUpdate(); + } + + } catch (SQLException e) { + throw new CloudRuntimeException("Adding columns for Extract Template And Volume functionality failed"); + } + } private void secondaryIpsAccountAndDomainIdsUpdate(Connection conn) { PreparedStatement pstmt = null; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9fd0655a/setup/db/db/schema-430to440.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql index 208c0ae..7e518e3 100644 --- a/setup/db/db/schema-430to440.sql +++ b/setup/db/db/schema-430to440.sql @@ -1705,7 +1705,3 @@ alter table `cloud`.`vlan` add column created datetime NULL COMMENT 'date create alter table `cloud`.`user_ip_address` drop key public_ip_address; alter table `cloud`.`user_ip_address` add UNIQUE KEY public_ip_address (public_ip_address,source_network_id, removed); -ALTER TABLE `cloud`.`volume_store_ref` ADD `download_url_created` datetime; -ALTER TABLE `cloud`.`template_store_ref` ADD `download_url_created` datetime; -ALTER TABLE `cloud`.`template_store_ref` ADD `download_url` varchar(255); -