ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-18640. Ambari upgrade failed while running "Alter Table blueprint" - blueprint_name column.(vbrodetskyi)
Date Thu, 20 Oct 2016 11:10:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 45ccfaf01 -> 9e8ad6614


AMBARI-18640. Ambari upgrade failed while running "Alter Table blueprint" - blueprint_name
column.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e8ad661
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e8ad661
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e8ad661

Branch: refs/heads/branch-2.4
Commit: 9e8ad661446e5e0aad10ea191b18056a85301e05
Parents: 45ccfaf
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Thu Oct 20 00:55:24 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Thu Oct 20 00:55:24 2016 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog242.java       | 20 ++++++++++++++++++++
 .../server/upgrade/UpgradeCatalog242Test.java   | 13 +++++++++++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9e8ad661/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
index 6fa3e68..a5276c2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
@@ -38,6 +38,9 @@ public class UpgradeCatalog242 extends AbstractUpgradeCatalog {
   protected static final String USERS_TABLE = "users";
   protected static final String HOST_ROLE_COMMAND_TABLE = "host_role_command";
   protected static final String BLUEPRINT_TABLE = "blueprint";
+  protected static final String HOST_GROUP_TABLE = "hostgroup";
+  protected static final String BLUEPRINT_CONFIGURATION = "blueprint_configuration";
+  protected static final String BLUEPRINT_SETTING = "blueprint_setting";
 
   protected static final String BLUEPRINT_NAME_COLUMN = "blueprint_name";
   protected static final String EXTENSION_NAME_COLUMN = "extension_name";
@@ -117,7 +120,24 @@ public class UpgradeCatalog242 extends AbstractUpgradeCatalog {
       dbAccessor.alterColumn(HOST_ROLE_COMMAND_TABLE, new DBAccessor.DBColumnInfo(ROLE_COLUMN,
String.class, 100, null, true));
       dbAccessor.alterColumn(HOST_ROLE_COMMAND_TABLE, new DBAccessor.DBColumnInfo(STATUS_COLUMN,
String.class, 100, null, true));
 
+      dbAccessor.dropFKConstraint(HOST_GROUP_TABLE, "FK_hg_blueprint_name");
+
+      dbAccessor.dropFKConstraint(BLUEPRINT_CONFIGURATION, "FK_cfg_blueprint_name");
+
+      dbAccessor.dropFKConstraint(BLUEPRINT_SETTING, "FK_blueprint_setting_name");
+
       dbAccessor.alterColumn(BLUEPRINT_TABLE, new DBAccessor.DBColumnInfo(BLUEPRINT_NAME_COLUMN,
String.class, 100, null, false));
+
+      String[] uniqueColumns = new String[] { BLUEPRINT_NAME_COLUMN };
+
+      dbAccessor.addFKConstraint(HOST_GROUP_TABLE, "FK_hg_blueprint_name",
+              uniqueColumns, BLUEPRINT_TABLE, uniqueColumns, false);
+
+      dbAccessor.addFKConstraint(BLUEPRINT_CONFIGURATION, "FK_cfg_blueprint_name",
+              uniqueColumns, BLUEPRINT_TABLE, uniqueColumns, false);
+
+      dbAccessor.addFKConstraint(BLUEPRINT_SETTING, "FK_blueprint_setting_name",
+              uniqueColumns, BLUEPRINT_TABLE, uniqueColumns, false);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9e8ad661/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog242Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog242Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog242Test.java
index 81f8451..4457858 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog242Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog242Test.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.upgrade;
 
 import javax.persistence.EntityManager;
 import junit.framework.Assert;
+import static org.easymock.EasyMock.aryEq;
 import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.createMockBuilder;
 import static org.easymock.EasyMock.createNiceMock;
@@ -125,8 +126,20 @@ public class UpgradeCatalog242Test {
     dbAccessor.alterColumn(eq(UpgradeCatalog242.HOST_ROLE_COMMAND_TABLE), capture(hostRoleCommandRoleColumnChangeSize));
     dbAccessor.alterColumn(eq(UpgradeCatalog242.HOST_ROLE_COMMAND_TABLE), capture(hostRoleCommandStatusColumnChangeSize));
 
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog242.HOST_GROUP_TABLE), eq("FK_hg_blueprint_name"));
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog242.BLUEPRINT_CONFIGURATION), eq("FK_cfg_blueprint_name"));
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog242.BLUEPRINT_SETTING), eq("FK_blueprint_setting_name"));
+
     dbAccessor.alterColumn(eq(UpgradeCatalog242.BLUEPRINT_TABLE), capture(blueprintBlueprintNameColumnChangeSize));
 
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog242.HOST_GROUP_TABLE), eq("FK_hg_blueprint_name"),
+            aryEq(new String[]{"blueprint_name"}), eq(UpgradeCatalog242.BLUEPRINT_TABLE),
aryEq(new String[]{"blueprint_name"}), eq(false));
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog242.BLUEPRINT_CONFIGURATION), eq("FK_cfg_blueprint_name"),
+            aryEq(new String[]{"blueprint_name"}), eq(UpgradeCatalog242.BLUEPRINT_TABLE),
aryEq(new String[]{"blueprint_name"}), eq(false));
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog242.BLUEPRINT_SETTING), eq("FK_blueprint_setting_name"),
+            aryEq(new String[]{"blueprint_name"}), eq(UpgradeCatalog242.BLUEPRINT_TABLE),
aryEq(new String[]{"blueprint_name"}), eq(false));
 
     replay(dbAccessor, configuration);
     Module module = new Module() {


Mime
View raw message