cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to 81d3a9e
Date Fri, 30 May 2014 21:56:13 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 5393387bb -> 81d3a9e3e


CLOUDSTACK-6599: Add the column in Java upgrade path since 4.2 already has the extract template/volume
columns
(cherry picked from commit be765ce8680564b743a73dd360c590c0e495c204)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/81d3a9e3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/81d3a9e3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/81d3a9e3

Branch: refs/heads/master
Commit: 81d3a9e3ee64f6f25484865e831b375ce13ec914
Parents: 5393387
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Fri May 30 14:53:42 2014 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Fri May 30 14:56:05 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade430to440.java  | 33 ++++++++++++++++++++
 setup/db/db/schema-430to440.sql                 |  4 ---
 2 files changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81d3a9e3/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 da71d44..b7b6bc4 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java
@@ -61,8 +61,41 @@ public class Upgrade430to440 implements DbUpgrade {
     public void performDataMigration(Connection conn) {
         secondaryIpsAccountAndDomainIdsUpdate(conn);
         moveCidrsToTheirOwnTable(conn);
+        addExtractTemplateAndVolumeColumns(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/81d3a9e3/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index 1d0a79a..735bbbe 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -1686,7 +1686,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);
-


Mime
View raw message