ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [31/35] ambari git commit: AMBARI-21728. Service and Patch Upgrade Catalog Changes for 2.6 - additional fixes (dlysnichenko)
Date Tue, 22 Aug 2017 18:02:47 GMT
AMBARI-21728. Service and Patch Upgrade Catalog Changes for 2.6 - additional fixes (dlysnichenko)


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

Branch: refs/heads/branch-feature-logsearch-ui
Commit: dee7317e000879313da9d7a08614331daae57e3a
Parents: d2e0c42
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Tue Aug 22 19:26:30 2017 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Tue Aug 22 19:26:30 2017 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/orm/DBAccessor.java    |  55 +++
 .../ambari/server/orm/DBAccessorImpl.java       | 119 +++++
 .../server/orm/helpers/dbms/DbmsHelper.java     |  27 ++
 .../orm/helpers/dbms/GenericDbmsHelper.java     |  14 +
 .../server/orm/helpers/dbms/H2Helper.java       |  16 +
 .../server/orm/helpers/dbms/MySqlHelper.java    |  16 +
 .../server/orm/helpers/dbms/OracleHelper.java   |  16 +
 .../server/orm/helpers/dbms/PostgresHelper.java |  15 +
 .../server/upgrade/SchemaUpgradeHelper.java     |   1 +
 .../server/upgrade/UpgradeCatalog252.java       |  51 ++
 .../server/upgrade/UpgradeCatalog260.java       | 325 +++++++++++++
 .../server/upgrade/UpgradeCatalog300.java       |  97 +---
 .../ambari/server/orm/DBAccessorImplTest.java   |  88 ++++
 .../server/upgrade/UpgradeCatalog260Test.java   | 468 +++++++++++++++++++
 .../server/upgrade/UpgradeCatalog300Test.java   |  74 ---
 15 files changed, 1212 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
index ef343d5..549c0fd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
@@ -367,6 +367,21 @@ public interface DBAccessor {
   void executePreparedUpdate(String query, boolean ignoreFailure, Object...arguments) throws SQLException;
 
   /**
+   * Execute select {@code columnName} from {@code tableName}
+   * where {@code columnNames} values = {@code values}
+   *
+   * @param tableName
+   * @param columnName
+   * @param columnNames
+   * @param values
+   * @param ignoreFailure
+   * @return
+   * @throws SQLException
+   */
+  List<Integer> getIntColumnValues(String tableName, String columnName, String[] columnNames,
+                                   String[] values, boolean ignoreFailure) throws SQLException;
+
+  /**
    * Drop table from schema
    * @param tableName
    * @throws SQLException
@@ -689,6 +704,46 @@ public interface DBAccessor {
   void moveColumnToAnotherTable(String sourceTableName, DBColumnInfo sourceColumn, String sourceIDFieldName,
        String targetTableName, DBColumnInfo targetColumn, String targetIDFieldName, Object initialValue) throws SQLException;
 
+  /**
+   * Copy column from {@code targetTable} by matching
+   * table keys {@code sourceIDColumnName} and {@code targetIDColumnName}
+   * and condition {@code sourceConditionFieldName} = {@code condition}
+   *
+   * @param sourceTableName          the source table name
+   * @param sourceColumn             the source column name
+   * @param sourceIDFieldName1       the source id key filed name matched with {@code targetIDFieldName1}
+   * @param sourceIDFieldName2       the source id key filed name matched with {@code targetIDFieldName2}
+   * @param sourceIDFieldName3       the source id key filed name matched with {@code targetIDFieldName3}
+   * @param targetTableName          the target table name
+   * @param targetColumn             the target column name
+   * @param targetIDFieldName1       the target id key name matched with {@code sourceIDFieldName1}
+   * @param targetIDFieldName2       the target id key name matched with {@code sourceIDFieldName2}
+   * @param targetIDFieldName3       the target id key name matched with {@code sourceIDFieldName3}
+   * @param sourceConditionFieldName source key column name which should match {@code condition}
+   * @param condition                value which should match {@code sourceConditionFieldName}
+   * @param initialValue             initial value for null-contained cells
+   * @throws SQLException
+   */
+  void copyColumnToAnotherTable(String sourceTableName, DBColumnInfo sourceColumn, String sourceIDFieldName1, String sourceIDFieldName2, String sourceIDFieldName3,
+                                String targetTableName, DBColumnInfo targetColumn, String targetIDFieldName1, String targetIDFieldName2, String targetIDFieldName3,
+                                String sourceConditionFieldName, String condition, Object initialValue) throws SQLException;
+
+  /**
+   * Remove all rows from the table
+   *
+   * @param tableName name of the table
+   */
+  void clearTable(String tableName) throws SQLException;
+
+  /**
+   * Reset all rows with {@code value} for {@code columnName} column
+   *
+   * @param tableName  name of the table
+   * @param columnName name of the column name to be update
+   * @param value      data to use for update
+   */
+  void clearTableColumn(String tableName, String columnName, Object value) throws SQLException;
+
   enum DbType {
     ORACLE,
     MYSQL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index 04e4c66..b137705 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -1400,6 +1400,101 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   /**
+   * {@inheritDoc}
+   */
+  @Override
+  public void copyColumnToAnotherTable(String sourceTableName, DBColumnInfo sourceColumn, String sourceIDFieldName1, String sourceIDFieldName2, String sourceIDFieldName3,
+                                       String targetTableName, DBColumnInfo targetColumn, String targetIDFieldName1, String targetIDFieldName2, String targetIDFieldName3,
+                                       String sourceConditionFieldName, String condition, Object initialValue) throws SQLException {
+
+    if (tableHasColumn(sourceTableName, sourceIDFieldName1) &&
+        tableHasColumn(sourceTableName, sourceIDFieldName2) &&
+        tableHasColumn(sourceTableName, sourceIDFieldName3) &&
+        tableHasColumn(sourceTableName, sourceColumn.getName()) &&
+        tableHasColumn(sourceTableName, sourceConditionFieldName) &&
+        tableHasColumn(targetTableName, targetIDFieldName1) &&
+        tableHasColumn(targetTableName, targetIDFieldName2) &&
+        tableHasColumn(targetTableName, targetIDFieldName3)
+        ) {
+
+      final String moveSQL = dbmsHelper.getCopyColumnToAnotherTableStatement(sourceTableName, sourceColumn.getName(),
+          sourceIDFieldName1, sourceIDFieldName2, sourceIDFieldName3, targetTableName, targetColumn.getName(),
+          targetIDFieldName1, targetIDFieldName2, targetIDFieldName3, sourceConditionFieldName, condition);
+      final boolean isTargetColumnNullable = targetColumn.isNullable();
+
+      targetColumn.setNullable(true);  // setting column nullable by default to move rows with null
+
+      addColumn(targetTableName, targetColumn);
+      executeUpdate(moveSQL, false);
+
+      if (initialValue != null) {
+        String updateSQL = dbmsHelper.getColumnUpdateStatementWhereColumnIsNull(convertObjectName(targetTableName),
+            convertObjectName(targetColumn.getName()), convertObjectName(targetColumn.getName()));
+
+        executePreparedUpdate(updateSQL, initialValue);
+      }
+
+      if (!isTargetColumnNullable) {
+        setColumnNullable(targetTableName, targetColumn.getName(), false);
+      }
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public List<Integer> getIntColumnValues(String tableName, String columnName, String[] ConditionColumnNames,
+                                          String[] values, boolean ignoreFailure) throws SQLException {
+
+    if (!tableHasColumn(tableName, columnName)) {
+      throw new IllegalArgumentException(String.format("%s table does not contain %s column", tableName, columnName));
+    }
+    StringBuilder builder = new StringBuilder();
+    builder.append("SELECT ").append(columnName).append(" FROM ").append(tableName);
+    if (ConditionColumnNames != null && ConditionColumnNames.length > 0) {
+      for (String name : ConditionColumnNames) {
+        if (!tableHasColumn(tableName, name)) {
+          throw new IllegalArgumentException(String.format("%s table does not contain %s column", tableName, name));
+        }
+      }
+      if (ConditionColumnNames.length != values.length) {
+        throw new IllegalArgumentException("number of columns should be equal to number of values");
+      }
+      builder.append(" WHERE ").append(ConditionColumnNames[0]).append("='").append(values[0]).append("'");
+      for (int i = 1; i < ConditionColumnNames.length; i++) {
+        builder.append(" AND ").append(ConditionColumnNames[i]).append("='").append(values[i]).append("'");
+      }
+    }
+
+    List<Integer> result = new ArrayList<>();
+    Statement statement = getConnection().createStatement();
+    ResultSet resultSet = null;
+    String query = builder.toString();
+    try {
+      resultSet = statement.executeQuery(query);
+      if (resultSet != null) {
+        while (resultSet.next()) {
+          result.add(resultSet.getInt(1));
+        }
+      }
+    } catch (SQLException e) {
+      LOG.warn("Unable to execute query: " + query, e);
+      if (!ignoreFailure) {
+        throw e;
+      }
+    } finally {
+      if (resultSet != null) {
+        resultSet.close();
+      }
+      if (statement != null) {
+        statement.close();
+      }
+    }
+    return result;
+  }
+
+  /**
    * Move column data from {@code sourceTableName} to {@code targetTableName} using {@code sourceIDFieldName} and
    * {@code targetIDFieldName} keys to match right rows
    *
@@ -1450,4 +1545,28 @@ public class DBAccessorImpl implements DBAccessor {
       dropColumn(sourceTableName, sourceColumn.getName());
     }
   }
+
+  /**
+   * Remove all rows from the table
+   *
+   * @param tableName name of the table
+   */
+  @Override
+  public void clearTable(String tableName) throws SQLException {
+    String sqlQuery = "DELETE FROM " + convertObjectName(tableName);
+    executeQuery(sqlQuery);
+  }
+
+  /**
+   * Reset all rows with {@code value} for {@code columnName} column
+   *
+   * @param tableName  name of the table
+   * @param columnName
+   * @param value      data to use for update
+   */
+  @Override
+  public void clearTableColumn(String tableName, String columnName, Object value) throws SQLException {
+    String sqlQuery = String.format("UPDATE %s SET %s = ?", convertObjectName(tableName), convertObjectName(columnName));
+    executePreparedUpdate(sqlQuery, value);
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
index b30d01b..e3129d8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
@@ -158,6 +158,33 @@ public interface DbmsHelper {
                                               String targetTable, String targetColumnName, String targetIDColumnName);
 
   /**
+   * Get's the {@code UPDATE} statement for {@code sourceTable} for copy column from {@code targetTable} by matching
+   * table keys {@code sourceIDColumnName} and {@code targetIDColumnName}
+   * and condition {@code sourceConditionFieldName} = {@code condition}
+   *
+   * @param sourceTable              the source table name
+   * @param sourceColumnName         the source column name
+   * @param sourceIDColumnName1      source key id column which would be used to math right rows for {@code targetTable}
+   * @param sourceIDColumnName2      source key id column which would be used to math right rows for {@code targetTable}
+   * @param sourceIDColumnName3      source key id column which would be used to math right rows for {@code targetTable}
+   * @param targetTable              the destination table name
+   * @param targetColumnName         the destination column name
+   * @param targetIDColumnName1      destination key id column name which should match {@code sourceIDColumnName1}
+   * @param targetIDColumnName2      destination key id column name which should match {@code sourceIDColumnName1}
+   * @param targetIDColumnName3      destination key id column name which should match {@code sourceIDColumnName1}
+   * @param sourceConditionFieldName source key column name which should match {@code condition}
+   * @param condition                value which should match {@code sourceConditionFieldName}
+   * @return
+   */
+  String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                              String sourceIDColumnName1, String sourceIDColumnName2,
+                                              String sourceIDColumnName3,
+                                              String targetTable, String targetColumnName,
+                                              String targetIDColumnName1, String targetIDColumnName2,
+                                              String targetIDColumnName3,
+                                              String sourceConditionFieldName, String condition);
+
+  /**
    * Gets whether the database platform supports adding contraints after the
    * {@code NULL} constraint. Some database, such as Oracle, don't allow this.
    * Unfortunately, EclipsLink hard codes the order of constraints.

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
index e2a1f38..24665c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
@@ -86,6 +86,20 @@ public class GenericDbmsHelper implements DbmsHelper {
     throw new UnsupportedOperationException("Column copy is not supported for generic DB");
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                                     String sourceIDColumnName1, String sourceIDColumnName2,
+                                                     String sourceIDColumnName3,
+                                                     String targetTable, String targetColumnName,
+                                                     String targetIDColumnName1, String targetIDColumnName2,
+                                                     String targetIDColumnName3,
+                                                     String sourceConditionFieldName, String condition) {
+    throw new UnsupportedOperationException("Column copy is not supported for generic DB");
+  }
+
   public StringBuilder writeAlterTableClause(StringBuilder builder, String tableName) {
     builder.append("ALTER TABLE ").append(tableName).append(" ");
     return builder;

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/H2Helper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/H2Helper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/H2Helper.java
index 91905e4..93b3bf9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/H2Helper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/H2Helper.java
@@ -81,4 +81,20 @@ public class H2Helper extends GenericDbmsHelper {
     return String.format("UPDATE %1$s a SET %3$s = (SELECT b.%4$s FROM %2$s b WHERE b.%6$s = a.%5$s LIMIT 1)",
       targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName, sourceIDColumnName);
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                                     String sourceIDColumnName1, String sourceIDColumnName2,
+                                                     String sourceIDColumnName3,
+                                                     String targetTable, String targetColumnName,
+                                                     String targetIDColumnName1, String targetIDColumnName2,
+                                                     String targetIDColumnName3,
+                                                     String sourceConditionFieldName, String condition) {
+    return String.format("UPDATE %1$s a SET %3$s = (SELECT b.%4$s FROM %2$s b WHERE b.%8$s = a.%5$s AND b.%9$s = a.%6$s AND b.%10$s = a.%7$s AND b.%11$s = '%12$s'  LIMIT 1)",
+        targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName1, targetIDColumnName2, targetIDColumnName3,
+        sourceIDColumnName1, sourceIDColumnName2, sourceIDColumnName3, sourceConditionFieldName, condition);
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/MySqlHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/MySqlHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/MySqlHelper.java
index 0daea72..4f8478e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/MySqlHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/MySqlHelper.java
@@ -105,4 +105,20 @@ public class MySqlHelper extends GenericDbmsHelper {
       targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName, sourceIDColumnName);
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                                     String sourceIDColumnName1, String sourceIDColumnName2,
+                                                     String sourceIDColumnName3,
+                                                     String targetTable, String targetColumnName,
+                                                     String targetIDColumnName1, String targetIDColumnName2,
+                                                     String targetIDColumnName3,
+                                                     String sourceConditionFieldName, String condition) {
+    return String.format("UPDATE %1$s AS a INNER JOIN %2$s AS b ON a.%5$s = b.%8$s AND a.%6$s = b.%9$s AND a.%7$s = b.%10$s AND b.%11$s = '%12$s' SET a.%3$s = b.%4$s",
+        targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName1, targetIDColumnName2, targetIDColumnName3,
+        sourceIDColumnName1, sourceIDColumnName2, sourceIDColumnName3, sourceConditionFieldName, condition);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/OracleHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/OracleHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/OracleHelper.java
index 73356d1..fd512c2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/OracleHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/OracleHelper.java
@@ -91,4 +91,20 @@ public class OracleHelper extends GenericDbmsHelper {
     return String.format("UPDATE %1$s a SET (a.%3$s) = (SELECT b.%4$s FROM %2$s b WHERE b.%6$s = a.%5$s and ROWNUM < 2)",
       targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName, sourceIDColumnName);
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                                     String sourceIDColumnName1, String sourceIDColumnName2,
+                                                     String sourceIDColumnName3,
+                                                     String targetTable, String targetColumnName,
+                                                     String targetIDColumnName1, String targetIDColumnName2,
+                                                     String targetIDColumnName3,
+                                                     String sourceConditionFieldName, String condition) {
+    return String.format("UPDATE %1$s a SET (a.%3$s) = (SELECT b.%4$s FROM %2$s b WHERE b.%8$s = a.%5$s AND b.%9$s = a.%6$s AND b.%10$s = a.%7$s AND b.%11$s = '%12$s' AND ROWNUM < 2)",
+        targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName1, targetIDColumnName2, targetIDColumnName3,
+        sourceIDColumnName1, sourceIDColumnName2, sourceIDColumnName3, sourceConditionFieldName, condition);
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/PostgresHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/PostgresHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/PostgresHelper.java
index 37c1184..a173bbd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/PostgresHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/PostgresHelper.java
@@ -55,6 +55,21 @@ public class PostgresHelper extends GenericDbmsHelper {
       targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName, sourceIDColumnName);
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getCopyColumnToAnotherTableStatement(String sourceTable, String sourceColumnName,
+                                                     String sourceIDColumnName1, String sourceIDColumnName2,
+                                                     String sourceIDColumnName3,
+                                                     String targetTable, String targetColumnName,
+                                                     String targetIDColumnName1, String targetIDColumnName2,
+                                                     String targetIDColumnName3,
+                                                     String sourceConditionFieldName, String condition) {
+    return String.format("UPDATE %1$s AS a SET %3$s = b.%4$s FROM %2$s AS b WHERE a.%5$s = b.%8$s AND a.%6$s = b.%9$s AND a.%7$s = b.%10$s AND b.%11$s = '%12$s'",
+        targetTable, sourceTable, targetColumnName, sourceColumnName, targetIDColumnName1, targetIDColumnName2, targetIDColumnName3,
+        sourceIDColumnName1, sourceIDColumnName2, sourceIDColumnName3, sourceConditionFieldName, condition);
+  }
 
   @Override
   public StringBuilder writeSetNullableString(StringBuilder builder,

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
index bcc8328..8812ef5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
@@ -178,6 +178,7 @@ public class SchemaUpgradeHelper {
         Multibinder.newSetBinder(binder(), UpgradeCatalog.class);
       catalogBinder.addBinding().to(UpgradeCatalog251.class);
       catalogBinder.addBinding().to(UpgradeCatalog252.class);
+      catalogBinder.addBinding().to(UpgradeCatalog260.class);
       catalogBinder.addBinding().to(UpgradeCatalog300.class);
       catalogBinder.addBinding().to(FinalUpgradeCatalog.class);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog252.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog252.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog252.java
index 1192c11..b83ba64 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog252.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog252.java
@@ -21,6 +21,7 @@ import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -55,8 +56,22 @@ public class UpgradeCatalog252 extends AbstractUpgradeCatalog {
   static final String CLUSTERCONFIG_TABLE = "clusterconfig";
   static final String SERVICE_DELETED_COLUMN = "service_deleted";
 
+  private static final String UPGRADE_TABLE = "upgrade";
+  private static final String UPGRADE_TABLE_FROM_REPO_COLUMN = "from_repo_version_id";
+  private static final String UPGRADE_TABLE_TO_REPO_COLUMN = "to_repo_version_id";
+  private static final String CLUSTERS_TABLE = "clusters";
+  private static final String SERVICE_COMPONENT_HISTORY_TABLE = "servicecomponent_history";
+  private static final String UPGRADE_GROUP_TABLE = "upgrade_group";
+  private static final String UPGRADE_ITEM_TABLE = "upgrade_item";
+  private static final String UPGRADE_ID_COLUMN = "upgrade_id";
+
   private static final String CLUSTER_ENV = "cluster-env";
 
+  private static final String HIVE_ENV = "hive-env";
+  private static final String MARIADB_REDHAT_SUPPORT = "mariadb_redhat_support";
+
+  private static final List<String> configTypesToEnsureSelected = Arrays.asList("spark2-javaopts-properties");
+
   /**
    * Logger.
    */
@@ -94,6 +109,7 @@ public class UpgradeCatalog252 extends AbstractUpgradeCatalog {
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
     addServiceDeletedColumnToClusterConfigTable();
+    addRepositoryColumnsToUpgradeTable();
   }
 
   /**
@@ -126,6 +142,41 @@ public class UpgradeCatalog252 extends AbstractUpgradeCatalog {
   }
 
   /**
+   * Changes the following columns to {@value #UPGRADE_TABLE}:
+   * <ul>
+   * <li>{@value #UPGRADE_TABLE_FROM_REPO_COLUMN}
+   * <li>{@value #UPGRADE_TABLE_TO_REPO_COLUMN}
+   * <li>Removes {@code to_version}
+   * <li>Removes {@code from_version}
+   * </ul>
+   *
+   * @throws SQLException
+   */
+  private void addRepositoryColumnsToUpgradeTable() throws SQLException {
+    dbAccessor.clearTableColumn(CLUSTERS_TABLE, UPGRADE_ID_COLUMN, null);
+    dbAccessor.clearTable(SERVICE_COMPONENT_HISTORY_TABLE);
+    dbAccessor.clearTable(SERVICE_COMPONENT_HISTORY_TABLE);
+    dbAccessor.clearTable(UPGRADE_ITEM_TABLE);
+    dbAccessor.clearTable(UPGRADE_GROUP_TABLE);
+    dbAccessor.clearTable(UPGRADE_TABLE);
+
+    dbAccessor.dropColumn(UPGRADE_TABLE, "to_version");
+    dbAccessor.dropColumn(UPGRADE_TABLE, "from_version");
+
+    dbAccessor.addColumn(UPGRADE_TABLE,
+        new DBColumnInfo(UPGRADE_TABLE_FROM_REPO_COLUMN, Long.class, null, null, false));
+
+    dbAccessor.addFKConstraint(UPGRADE_TABLE, "FK_upgrade_from_repo_id",
+        UPGRADE_TABLE_FROM_REPO_COLUMN, "repo_version", "repo_version_id", false);
+
+    dbAccessor.addColumn(UPGRADE_TABLE,
+        new DBColumnInfo(UPGRADE_TABLE_TO_REPO_COLUMN, Long.class, null, null, false));
+
+    dbAccessor.addFKConstraint(UPGRADE_TABLE, "FK_upgrade_to_repo_id",
+        UPGRADE_TABLE_FROM_REPO_COLUMN, "repo_version", "repo_version_id", false);
+  }
+
+  /**
    * Resets the following properties in {@code cluster-env} to their new
    * defaults:
    * <ul>

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java
new file mode 100644
index 0000000..ce84cc6
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java
@@ -0,0 +1,325 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+package org.apache.ambari.server.upgrade;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.orm.DBAccessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * The {@link org.apache.ambari.server.upgrade.UpgradeCatalog260} upgrades Ambari from 2.5.2 to 2.6.0.
+ */
+public class UpgradeCatalog260 extends AbstractUpgradeCatalog {
+
+  public static final String CLUSTER_CONFIG_MAPPING_TABLE = "clusterconfigmapping";
+  public static final String CLUSTER_VERSION_TABLE = "cluster_version";
+  public static final String CLUSTER_ID_COLUMN = "cluster_id";
+  public static final String STATE_COLUMN = "state";
+  public static final String CREATE_TIMESTAMP_COLUMN = "create_timestamp";
+  public static final String VERSION_TAG_COLUMN = "version_tag";
+  public static final String TYPE_NAME_COLUMN = "type_name";
+
+  public static final String CLUSTER_CONFIG_TABLE = "clusterconfig";
+  public static final String SELECTED_COLUMN = "selected";
+  public static final String SELECTED_TIMESTAMP_COLUMN = "selected_timestamp";
+
+  public static final String SERVICE_COMPONENT_DESIRED_STATE_TABLE = "servicecomponentdesiredstate";
+  public static final String DESIRED_STACK_ID_COLUMN = "desired_stack_id";
+  public static final String DESIRED_VERSION_COLUMN = "desired_version";
+  public static final String DESIRED_REPO_VERSION_ID_COLUMN = "desired_repo_version_id";
+  public static final String REPO_STATE_COLUMN = "repo_state";
+  public static final String FK_SCDS_DESIRED_STACK_ID = "FK_scds_desired_stack_id";
+  public static final String FK_SCDS_DESIRED_REPO_ID = "FK_scds_desired_repo_id";
+
+  public static final String REPO_VERSION_TABLE = "repo_version";
+  public static final String REPO_VERSION_ID_COLUMN = "repo_version_id";
+
+  public static final String HOST_COMPONENT_DESIRED_STATE_TABLE = "hostcomponentdesiredstate";
+  public static final String FK_HCDS_DESIRED_STACK_ID = "FK_hcds_desired_stack_id";
+
+  public static final String HOST_COMPONENT_STATE_TABLE = "hostcomponentstate";
+  public static final String CURRENT_STACK_ID_COLUMN = "current_stack_id";
+  public static final String FK_HCS_CURRENT_STACK_ID = "FK_hcs_current_stack_id";
+
+  public static final String HOST_VERSION_TABLE = "host_version";
+  public static final String UQ_HOST_REPO = "UQ_host_repo";
+  public static final String HOST_ID_COLUMN = "host_id";
+
+  public static final String SERVICE_DESIRED_STATE_TABLE = "servicedesiredstate";
+  public static final String FK_SDS_DESIRED_STACK_ID = "FK_sds_desired_stack_id";
+  public static final String FK_REPO_VERSION_ID = "FK_repo_version_id";
+
+  public static final String UPGRADE_TABLE = "upgrade";
+  public static final String FROM_REPO_VERSION_ID_COLUMN = "from_repo_version_id";
+  public static final String TO_REPO_VERSION_ID_COLUMN = "to_repo_version_id";
+  public static final String ORCHESTRATION_COLUMN = "orchestration";
+  public static final String FK_UPGRADE_FROM_REPO_ID = "FK_upgrade_from_repo_id";
+  public static final String FK_UPGRADE_TO_REPO_ID = "FK_upgrade_to_repo_id";
+  public static final String FK_UPGRADE_REPO_VERSION_ID = "FK_upgrade_repo_version_id";
+
+  public static final String SERVICE_COMPONENT_HISTORY_TABLE = "servicecomponent_history";
+  public static final String UPGRADE_HISTORY_TABLE = "upgrade_history";
+  public static final String ID_COLUMN = "id";
+  public static final String UPGRADE_ID_COLUMN = "upgrade_id";
+  public static final String SERVICE_NAME_COLUMN = "service_name";
+  public static final String COMPONENT_NAME_COLUMN = "component_name";
+  public static final String TARGET_REPO_VERSION_ID_COLUMN = "target_repo_version_id";
+  public static final String PK_UPGRADE_HIST = "PK_upgrade_hist";
+  public static final String FK_UPGRADE_HIST_UPGRADE_ID = "FK_upgrade_hist_upgrade_id";
+  public static final String FK_UPGRADE_HIST_FROM_REPO = "FK_upgrade_hist_from_repo";
+  public static final String FK_UPGRADE_HIST_TARGET_REPO = "FK_upgrade_hist_target_repo";
+  public static final String UQ_UPGRADE_HIST = "UQ_upgrade_hist";
+
+  /**
+   * Logger.
+   */
+  private static final Logger LOG = LoggerFactory.getLogger(UpgradeCatalog260.class);
+  public static final String STANDARD = "STANDARD";
+  public static final String NOT_REQUIRED = "NOT_REQUIRED";
+  public static final String CURRENT = "CURRENT";
+  public static final String SELECTED = "1";
+
+
+  /**
+   * Constructor.
+   *
+   * @param injector
+   */
+  @Inject
+  public UpgradeCatalog260(Injector injector) {
+    super(injector);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSourceVersion() {
+    return "2.5.2";
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getTargetVersion() {
+    return "2.6.0";
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected void executeDDLUpdates() throws AmbariException, SQLException {
+    int currentVersionID = getCurrentVersionID();
+    updateServiceComponentDesiredStateTable(currentVersionID);
+    updateServiceDesiredStateTable(currentVersionID);
+    addSelectedCollumsToClusterconfigTable();
+    updateHostComponentDesiredStateTable();
+    updateHostComponentStateTable();
+    updateUpgradeTable();
+    createUpgradeHistoryTable();
+    dropStaleTables();
+  }
+
+  private void createUpgradeHistoryTable() throws SQLException {
+    List<DBAccessor.DBColumnInfo> columns = new ArrayList<DBAccessor.DBColumnInfo>();
+
+    columns.add(new DBAccessor.DBColumnInfo(ID_COLUMN, Long.class, null, null, false));
+    columns.add(new DBAccessor.DBColumnInfo(UPGRADE_ID_COLUMN, Long.class, null, null, false));
+    columns.add(new DBAccessor.DBColumnInfo(SERVICE_NAME_COLUMN, String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo(COMPONENT_NAME_COLUMN, String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo(FROM_REPO_VERSION_ID_COLUMN, Long.class, null, null, false));
+    columns.add(new DBAccessor.DBColumnInfo(TARGET_REPO_VERSION_ID_COLUMN, Long.class, null, null, false));
+    dbAccessor.createTable(UPGRADE_HISTORY_TABLE, columns);
+
+    dbAccessor.addPKConstraint(UPGRADE_HISTORY_TABLE, PK_UPGRADE_HIST, ID_COLUMN);
+
+    dbAccessor.addFKConstraint(UPGRADE_HISTORY_TABLE, FK_UPGRADE_HIST_UPGRADE_ID, UPGRADE_ID_COLUMN, UPGRADE_TABLE, UPGRADE_ID_COLUMN, false);
+    dbAccessor.addFKConstraint(UPGRADE_HISTORY_TABLE, FK_UPGRADE_HIST_FROM_REPO, FROM_REPO_VERSION_ID_COLUMN, REPO_VERSION_TABLE, REPO_VERSION_ID_COLUMN, false);
+    dbAccessor.addFKConstraint(UPGRADE_HISTORY_TABLE, FK_UPGRADE_HIST_TARGET_REPO, TARGET_REPO_VERSION_ID_COLUMN, REPO_VERSION_TABLE, REPO_VERSION_ID_COLUMN, false);
+    dbAccessor.addUniqueConstraint(UPGRADE_HISTORY_TABLE, UQ_UPGRADE_HIST, UPGRADE_ID_COLUMN, COMPONENT_NAME_COLUMN, SERVICE_NAME_COLUMN);
+
+    addSequence("upgrade_history_id_seq", 0L, false);
+  }
+
+  /**
+   * Updates {@value #UPGRADE_TABLE} table.
+   * clear {@value #UPGRADE_TABLE} table
+   * Removes {@value #FROM_REPO_VERSION_ID_COLUMN} column.
+   * Removes {@value #TO_REPO_VERSION_ID_COLUMN} column.
+   * Adds the {@value #ORCHESTRATION_COLUMN} column.
+   * Adds the {@value #REPO_VERSION_ID_COLUMN} column.
+   * Removes {@value #FK_UPGRADE_FROM_REPO_ID} foreign key.
+   * Removes {@value #FK_UPGRADE_TO_REPO_ID} foreign key.
+   * adds {@value #FK_REPO_VERSION_ID} foreign key.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void updateUpgradeTable() throws SQLException {
+    dbAccessor.clearTable(UPGRADE_TABLE);
+    dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_FROM_REPO_ID);
+    dbAccessor.dropFKConstraint(UPGRADE_TABLE, FK_UPGRADE_TO_REPO_ID);
+    dbAccessor.dropColumn(UPGRADE_TABLE, FROM_REPO_VERSION_ID_COLUMN);
+    dbAccessor.dropColumn(UPGRADE_TABLE, TO_REPO_VERSION_ID_COLUMN);
+
+    dbAccessor.addColumn(UPGRADE_TABLE,
+        new DBAccessor.DBColumnInfo(REPO_VERSION_ID_COLUMN, Long.class, null, null, false));
+    dbAccessor.addColumn(UPGRADE_TABLE,
+        new DBAccessor.DBColumnInfo(ORCHESTRATION_COLUMN, String.class, 255, STANDARD, false));
+
+    dbAccessor.addFKConstraint(UPGRADE_TABLE, FK_UPGRADE_REPO_VERSION_ID, REPO_VERSION_ID_COLUMN, REPO_VERSION_TABLE, REPO_VERSION_ID_COLUMN, false);
+  }
+
+  /**
+   * Updates {@value #SERVICE_DESIRED_STATE_TABLE} table.
+   * Removes {@value #DESIRED_STACK_ID_COLUMN} column.
+   * Adds the {@value #DESIRED_REPO_VERSION_ID_COLUMN} column.
+   * Removes {@value #FK_SDS_DESIRED_STACK_ID} foreign key.
+   * adds {@value #FK_REPO_VERSION_ID} foreign key.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void updateServiceDesiredStateTable(int currentRepoID) throws SQLException {
+
+    dbAccessor.addColumn(SERVICE_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(DESIRED_REPO_VERSION_ID_COLUMN, Long.class, null, currentRepoID, false));
+    dbAccessor.alterColumn(SERVICE_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(DESIRED_REPO_VERSION_ID_COLUMN, Long.class, null, null, false));
+
+    dbAccessor.addFKConstraint(SERVICE_DESIRED_STATE_TABLE, FK_REPO_VERSION_ID, DESIRED_REPO_VERSION_ID_COLUMN, REPO_VERSION_TABLE, REPO_VERSION_ID_COLUMN, false);
+    dbAccessor.dropFKConstraint(SERVICE_DESIRED_STATE_TABLE, FK_SDS_DESIRED_STACK_ID);
+    dbAccessor.dropColumn(SERVICE_DESIRED_STATE_TABLE, DESIRED_STACK_ID_COLUMN);
+  }
+
+  /**
+   * drop {@value #CLUSTER_CONFIG_MAPPING_TABLE} and {@value #CLUSTER_VERSION_TABLE} tables.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void dropStaleTables() throws SQLException {
+    dbAccessor.dropTable(CLUSTER_CONFIG_MAPPING_TABLE);
+    dbAccessor.dropTable(CLUSTER_VERSION_TABLE);
+    dbAccessor.dropTable(SERVICE_COMPONENT_HISTORY_TABLE);
+  }
+
+  /**
+   * Adds the {@value #SELECTED_COLUMN} and {@value #SELECTED_TIMESTAMP_COLUMN} columns to the
+   * {@value #CLUSTER_CONFIG_TABLE} table.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void addSelectedCollumsToClusterconfigTable() throws SQLException {
+    DBAccessor.DBColumnInfo selectedColumnInfo = new DBAccessor.DBColumnInfo(SELECTED_COLUMN, Short.class, null, 0, false);
+    DBAccessor.DBColumnInfo selectedmappingColumnInfo = new DBAccessor.DBColumnInfo(SELECTED_COLUMN, Integer.class, null, 0, false);
+    DBAccessor.DBColumnInfo selectedTimestampColumnInfo = new DBAccessor.DBColumnInfo(SELECTED_TIMESTAMP_COLUMN, Long.class, null, 0, false);
+    DBAccessor.DBColumnInfo createTimestampColumnInfo = new DBAccessor.DBColumnInfo(CREATE_TIMESTAMP_COLUMN, Long.class, null, null, false);
+    dbAccessor.copyColumnToAnotherTable(CLUSTER_CONFIG_MAPPING_TABLE, selectedmappingColumnInfo,
+        CLUSTER_ID_COLUMN, TYPE_NAME_COLUMN, VERSION_TAG_COLUMN, CLUSTER_CONFIG_TABLE, selectedColumnInfo,
+        CLUSTER_ID_COLUMN, TYPE_NAME_COLUMN, VERSION_TAG_COLUMN, SELECTED_COLUMN, SELECTED, 0);
+
+    dbAccessor.copyColumnToAnotherTable(CLUSTER_CONFIG_MAPPING_TABLE, createTimestampColumnInfo,
+        CLUSTER_ID_COLUMN, TYPE_NAME_COLUMN, VERSION_TAG_COLUMN, CLUSTER_CONFIG_TABLE, selectedTimestampColumnInfo,
+        CLUSTER_ID_COLUMN, TYPE_NAME_COLUMN, VERSION_TAG_COLUMN, SELECTED_COLUMN, SELECTED, 0);
+  }
+
+
+  /**
+   * Updates {@value #SERVICE_COMPONENT_DESIRED_STATE_TABLE} table.
+   * Removes {@value #DESIRED_VERSION_COLUMN},{@value #DESIRED_STACK_ID_COLUMN} columns.
+   * Adds the {@value #DESIRED_REPO_VERSION_ID_COLUMN},{@value #REPO_STATE_COLUMN} columns.
+   * Removes {@value #FK_SCDS_DESIRED_STACK_ID} foreign key.
+   * adds {@value #FK_SCDS_DESIRED_REPO_ID} foreign key.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void updateServiceComponentDesiredStateTable(int currentRepoID) throws SQLException {
+    dbAccessor.addColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(DESIRED_REPO_VERSION_ID_COLUMN, Long.class, null, currentRepoID, false));
+    dbAccessor.alterColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(DESIRED_REPO_VERSION_ID_COLUMN, Long.class, null, null, false));
+
+    dbAccessor.addColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(REPO_STATE_COLUMN, String.class, 255, CURRENT, false));
+    dbAccessor.alterColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+        new DBAccessor.DBColumnInfo(REPO_STATE_COLUMN, String.class, 255, NOT_REQUIRED, false));
+
+    dbAccessor.addFKConstraint(SERVICE_COMPONENT_DESIRED_STATE_TABLE, FK_SCDS_DESIRED_REPO_ID, DESIRED_REPO_VERSION_ID_COLUMN, REPO_VERSION_TABLE, REPO_VERSION_ID_COLUMN, false);
+
+    dbAccessor.dropFKConstraint(SERVICE_COMPONENT_DESIRED_STATE_TABLE, FK_SCDS_DESIRED_STACK_ID);
+    dbAccessor.dropColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE, DESIRED_STACK_ID_COLUMN);
+    dbAccessor.dropColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE, DESIRED_VERSION_COLUMN);
+  }
+
+  /**
+   * Updates {@value #HOST_COMPONENT_DESIRED_STATE_TABLE} table.
+   * Removes {@value #DESIRED_STACK_ID_COLUMN} column.
+   * Removes {@value #FK_HCDS_DESIRED_STACK_ID} foreign key.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void updateHostComponentDesiredStateTable() throws SQLException {
+    dbAccessor.dropFKConstraint(HOST_COMPONENT_DESIRED_STATE_TABLE, FK_HCDS_DESIRED_STACK_ID);
+    dbAccessor.dropColumn(HOST_COMPONENT_DESIRED_STATE_TABLE, DESIRED_STACK_ID_COLUMN);
+  }
+
+  /**
+   * Updates {@value #HOST_COMPONENT_STATE_TABLE} table.
+   * Removes {@value #CURRENT_STACK_ID_COLUMN} column.
+   * Removes {@value #FK_HCS_CURRENT_STACK_ID} foreign key.
+   *
+   * @throws java.sql.SQLException
+   */
+  private void updateHostComponentStateTable() throws SQLException {
+    dbAccessor.dropFKConstraint(HOST_COMPONENT_STATE_TABLE, FK_HCS_CURRENT_STACK_ID);
+    dbAccessor.dropColumn(HOST_COMPONENT_STATE_TABLE, CURRENT_STACK_ID_COLUMN);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected void executePreDMLUpdates() throws AmbariException, SQLException {
+
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected void executeDMLUpdates() throws AmbariException, SQLException {
+    addNewConfigurationsFromXml();
+  }
+
+  public int getCurrentVersionID() throws AmbariException, SQLException {
+    List<Integer> currentVersionList = dbAccessor.getIntColumnValues(CLUSTER_VERSION_TABLE, REPO_VERSION_ID_COLUMN,
+        new String[]{STATE_COLUMN}, new String[]{CURRENT}, false);
+    if (currentVersionList.size() != 1) {
+      throw new AmbariException("Can't get current version id");
+    }
+    return currentVersionList.get(0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
index 230cd95..9255163 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
@@ -18,9 +18,7 @@
 package org.apache.ambari.server.upgrade;
 
 
-import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -40,7 +38,6 @@ import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.internal.CalculatedStatus;
 import org.apache.ambari.server.orm.DBAccessor;
-import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
 import org.apache.ambari.server.orm.dao.DaoUtils;
 import org.apache.ambari.server.orm.dao.RequestDAO;
 import org.apache.ambari.server.orm.entities.RequestEntity;
@@ -48,11 +45,9 @@ import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.support.JdbcUtils;
 
 import com.google.common.collect.Sets;
 import com.google.inject.Inject;
@@ -73,7 +68,6 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
   protected static final String CLUSTER_CONFIG_TABLE = "clusterconfig";
   protected static final String CLUSTER_CONFIG_SELECTED_COLUMN = "selected";
   protected static final String CLUSTER_CONFIG_SELECTED_TIMESTAMP_COLUMN = "selected_timestamp";
-  protected static final String CLUSTER_CONFIG_MAPPING_TABLE = "clusterconfigmapping";
   protected static final String HOST_ROLE_COMMAND_TABLE = "host_role_command";
   protected static final String HRC_OPS_DISPLAY_NAME_COLUMN = "ops_display_name";
   protected static final String COMPONENT_TABLE = "servicecomponentdesiredstate";
@@ -117,7 +111,7 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
    */
   @Override
   public String getSourceVersion() {
-    return "2.5.2";
+    return "2.6.0";
   }
 
   /**
@@ -125,9 +119,7 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
    */
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
-    addServiceComponentColumn();
     updateStageTable();
-    updateClusterConfigurationTable();
     addOpsDisplayNameColumnToHostRoleCommand();
     removeSecurityState();
   }
@@ -146,7 +138,6 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
    */
   @Override
   protected void executePreDMLUpdates() throws AmbariException, SQLException {
-    setSelectedConfigurationsAndRemoveMappingTable();
   }
 
   /**
@@ -181,17 +172,6 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
 
   }
 
-  /**
-   * Updates the {@code servicecomponentdesiredstate} table.
-   *
-   * @throws SQLException
-   */
-  protected void addServiceComponentColumn() throws SQLException {
-    dbAccessor.addColumn(COMPONENT_TABLE,
-        new DBColumnInfo("repo_state", String.class, 255,
-            RepositoryVersionState.NOT_REQUIRED.name(), false));
-  }
-
   protected void setStatusOfStagesAndRequests() {
     executeInTransaction(new Runnable() {
       @Override
@@ -231,81 +211,6 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
   }
 
   /**
-   * Performs the following operations on {@code clusterconfig}:
-   * <ul>
-   * <li>Adds the {@link #CLUSTER_CONFIG_SELECTED_COLUMN} to
-   * {@link #CLUSTER_CONFIG_TABLE}.
-   * <li>Adds the {@link #CLUSTER_CONFIG_SELECTED_TIMESTAMP_COLUMN} to
-   * {@link #CLUSTER_CONFIG_TABLE}.
-   * </ul>
-   */
-  protected void updateClusterConfigurationTable() throws SQLException {
-    dbAccessor.addColumn(CLUSTER_CONFIG_TABLE,
-        new DBAccessor.DBColumnInfo(CLUSTER_CONFIG_SELECTED_COLUMN, Short.class, null, 0, false));
-
-    dbAccessor.addColumn(CLUSTER_CONFIG_TABLE,
-        new DBAccessor.DBColumnInfo(CLUSTER_CONFIG_SELECTED_TIMESTAMP_COLUMN, Long.class, null, 0,
-            false));
-  }
-
-  /**
-   * Performs the following operations on {@code clusterconfig} and
-   * {@code clusterconfigmapping}:
-   * <ul>
-   * <li>Sets both selected columns to the current config by querying
-   * {@link #CLUSTER_CONFIG_MAPPING_TABLE}.
-   * <li>Removes {@link #CLUSTER_CONFIG_MAPPING_TABLE}.
-   * </ul>
-   */
-  protected void setSelectedConfigurationsAndRemoveMappingTable() throws SQLException {
-    // update the new selected columns
-    executeInTransaction(new Runnable() {
-      /**
-       * {@inheritDoc}
-       */
-      @Override
-      public void run() {
-        String selectSQL = String.format(
-            "SELECT cluster_id, type_name, version_tag FROM %s WHERE selected = 1 ORDER BY cluster_id ASC, type_name ASC, version_tag ASC",
-            CLUSTER_CONFIG_MAPPING_TABLE);
-
-        Statement statement = null;
-        ResultSet resultSet = null;
-
-        long now = System.currentTimeMillis();
-
-        try {
-          statement = dbAccessor.getConnection().createStatement();
-          resultSet = statement.executeQuery(selectSQL);
-
-          while (resultSet.next()) {
-            final Long clusterId = resultSet.getLong("cluster_id");
-            final String typeName = resultSet.getString("type_name");
-            final String versionTag = resultSet.getString("version_tag");
-
-            // inefficient since this can be done with a single nested SELECT,
-            // but this way we can log what's happening which is more useful
-            String updateSQL = String.format(
-                "UPDATE %s SET selected = 1, selected_timestamp = %d WHERE cluster_id = %d AND type_name = '%s' AND version_tag = '%s'",
-                CLUSTER_CONFIG_TABLE, now, clusterId, typeName, versionTag);
-
-            dbAccessor.executeQuery(updateSQL);
-          }
-        } catch (SQLException sqlException) {
-          throw new RuntimeException(sqlException);
-        } finally {
-          JdbcUtils.closeResultSet(resultSet);
-          JdbcUtils.closeStatement(statement);
-        }
-      }
-    });
-
-    // if the above execution and committed the transaction, then we can remove
-    // the cluster configuration mapping table
-    dbAccessor.dropTable(CLUSTER_CONFIG_MAPPING_TABLE);
-  }
-
-  /**
    * Adds the {@value #HRC_OPS_DISPLAY_NAME_COLUMN} column to the
    * {@value #HOST_ROLE_COMMAND_TABLE} table.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
index b4ffbf1..29f9d91 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/DBAccessorImplTest.java
@@ -640,6 +640,94 @@ public class DBAccessorImplTest {
    }
 
   @Test
+  public void testCopyColumnToAnotherTable() throws Exception {
+    DBAccessorImpl dbAccessor = injector.getInstance(DBAccessorImpl.class);
+    String sourceTableName = getFreeTableName();
+    String targetTableName = getFreeTableName();
+    int testRowAmount = 10;
+
+    createMyTable(sourceTableName, "col1", "col2", "col3", "col4", "col5");
+    createMyTable(targetTableName, "col1", "col2", "col3");
+
+    for (Integer i = 0; i < testRowAmount; i++) {
+      dbAccessor.insertRow(sourceTableName,
+          new String[]{"id", "col1", "col2", "col3", "col4", "col5"},
+          new String[]{i.toString(), String.format("'1,%s'", i), String.format("'2,%s'", i * 2), String.format("'3,%s'", i * 3), String.format("'4,%s'", i * 4), String.format("'%s'", (i * 5) % 2)}, false);
+
+      dbAccessor.insertRow(targetTableName,
+          new String[]{"id", "col1", "col2", "col3"},
+          new String[]{i.toString(), String.format("'1,%s'", i), String.format("'2,%s'", i * 2), String.format("'3,%s'", i * 3)}, false);
+    }
+
+    DBColumnInfo sourceColumn = new DBColumnInfo("col4", String.class, null, null, false);
+    DBColumnInfo targetColumn = new DBColumnInfo("col4", String.class, null, null, false);
+
+    dbAccessor.copyColumnToAnotherTable(sourceTableName, sourceColumn, "id", "col1", "col2",
+        targetTableName, targetColumn, "id", "col1", "col2", "col5", "0", "initial");
+
+    Statement statement = dbAccessor.getConnection().createStatement();
+    ResultSet resultSet = statement.executeQuery("SELECT col4 FROM " + targetTableName + " ORDER BY id");
+
+    assertNotNull(resultSet);
+
+    List<String> response = new LinkedList<>();
+
+    while (resultSet.next()) {
+      response.add(resultSet.getString(1));
+    }
+
+    assertEquals(testRowAmount, response.toArray().length);
+    for (String row : response) {
+      System.out.println(row);
+    }
+
+
+    int i = 0;
+    for (String row : response) {
+      if (i % 2 == 0) {
+        assertEquals(String.format("4,%s", i * 4), row);
+      } else {
+        assertEquals("initial", row);
+      }
+      i++;
+    }
+
+  }
+
+  @Test
+  public void testGetIntColumnValues() throws Exception {
+    DBAccessorImpl dbAccessor = injector.getInstance(DBAccessorImpl.class);
+    String sourceTableName = getFreeTableName();
+    int testRowAmount = 10;
+
+    createMyTable(sourceTableName, "col1", "col2", "col3", "col4", "col5");
+
+    for (Integer i = 0; i < testRowAmount; i++) {
+      dbAccessor.insertRow(sourceTableName,
+          new String[]{"id", "col1", "col2", "col3", "col4", "col5"},
+          new String[]{i.toString(), String.format("'1,%s'", i), String.format("'2,%s'", i * 2), String.format("'3,%s'", i * 3), String.format("'4,%s'", i * 4), String.format("'%s'", (i * 5) % 2)}, false);
+    }
+
+    List<Integer> idList = dbAccessor.getIntColumnValues(sourceTableName, "id",
+        new String[]{"col1", "col5"}, new String[]{"1,0", "0"}, false);
+
+    assertEquals(idList.size(), 1);
+    assertEquals(idList.get(0), Integer.valueOf(0));
+
+    idList = dbAccessor.getIntColumnValues(sourceTableName, "id",
+        new String[]{"col5"}, new String[]{"0"}, false);
+
+    assertEquals(idList.size(), 5);
+
+    int i = 0;
+    for (Integer id : idList) {
+      assertEquals(id, Integer.valueOf(i * 2));
+      i++;
+    }
+
+  }
+
+  @Test
   public void testMoveNonexistentColumnIsNoop() throws Exception {
     DBAccessorImpl dbAccessor = injector.getInstance(DBAccessorImpl.class);
     String sourceTableName = getFreeTableName();

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog260Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog260Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog260Test.java
new file mode 100644
index 0000000..44b5d91
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog260Test.java
@@ -0,0 +1,468 @@
+/*
+ * 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.
+ */
+
+package org.apache.ambari.server.upgrade;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.KerberosHelper;
+import org.apache.ambari.server.controller.MaintenanceStateHelper;
+import org.apache.ambari.server.orm.DBAccessor;
+import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.stack.OsFamily;
+import org.easymock.Capture;
+import org.easymock.EasyMockRunner;
+import org.easymock.Mock;
+import org.easymock.MockType;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.google.gson.Gson;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+
+/**
+ * {@link UpgradeCatalog260} unit tests.
+ */
+@RunWith(EasyMockRunner.class)
+public class UpgradeCatalog260Test {
+
+  //  private Injector injector;
+  @Mock(type = MockType.STRICT)
+  private Provider<EntityManager> entityManagerProvider;
+
+  @Mock(type = MockType.NICE)
+  private EntityManager entityManager;
+
+  @Mock(type = MockType.NICE)
+  private DBAccessor dbAccessor;
+
+  @Mock(type = MockType.NICE)
+  private Configuration configuration;
+
+  @Mock(type = MockType.NICE)
+  private Connection connection;
+
+  @Mock(type = MockType.NICE)
+  private Statement statement;
+
+  @Mock(type = MockType.NICE)
+  private ResultSet resultSet;
+
+  @Mock(type = MockType.NICE)
+  private OsFamily osFamily;
+
+  @Mock(type = MockType.NICE)
+  private KerberosHelper kerberosHelper;
+
+  @Mock(type = MockType.NICE)
+  private ActionManager actionManager;
+
+  @Mock(type = MockType.NICE)
+  private Config config;
+
+  @Mock(type = MockType.STRICT)
+  private Service service;
+
+  @Mock(type = MockType.NICE)
+  private Clusters clusters;
+
+  @Mock(type = MockType.NICE)
+  private Cluster cluster;
+
+  @Mock(type = MockType.NICE)
+  private Injector injector;
+
+  @Before
+  public void init() {
+    reset(entityManagerProvider, injector);
+
+    expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
+
+    expect(injector.getInstance(Gson.class)).andReturn(null).anyTimes();
+    expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).anyTimes();
+    expect(injector.getInstance(KerberosHelper.class)).andReturn(kerberosHelper).anyTimes();
+
+    replay(entityManagerProvider, injector);
+  }
+
+  @After
+  public void tearDown() {
+  }
+
+  @Test
+  public void testExecuteDDLUpdates() throws Exception {
+
+    List<Integer> current = new ArrayList<Integer>();
+    current.add(1);
+
+    expect(dbAccessor.getConnection()).andReturn(connection).anyTimes();
+    expect(connection.createStatement()).andReturn(statement).anyTimes();
+    expect(statement.executeQuery(anyObject(String.class))).andReturn(resultSet).anyTimes();
+    expect(configuration.getDatabaseType()).andReturn(Configuration.DatabaseType.POSTGRES).anyTimes();
+
+
+    Capture<String[]> scdcaptureKey = newCapture();
+    Capture<String[]> scdcaptureValue = newCapture();
+    expectGetCurrentVersionID(current, scdcaptureKey, scdcaptureValue);
+
+    Capture<DBColumnInfo> scdstadd1 = newCapture();
+    Capture<DBColumnInfo> scdstalter1 = newCapture();
+    Capture<DBColumnInfo> scdstadd2 = newCapture();
+    Capture<DBColumnInfo> scdstalter2 = newCapture();
+    expectUpdateServiceComponentDesiredStateTable(scdstadd1, scdstalter1, scdstadd2, scdstalter2);
+
+    Capture<DBColumnInfo> sdstadd = newCapture();
+    Capture<DBColumnInfo> sdstalter = newCapture();
+    expectUpdateServiceDesiredStateTable(sdstadd, sdstalter);
+
+    Capture<DBColumnInfo> selectedColumnInfo = newCapture();
+    Capture<DBColumnInfo> selectedmappingColumnInfo = newCapture();
+    Capture<DBColumnInfo> selectedTimestampColumnInfo = newCapture();
+    Capture<DBColumnInfo> createTimestampColumnInfo = newCapture();
+    expectAddSelectedCollumsToClusterconfigTable(selectedColumnInfo, selectedmappingColumnInfo, selectedTimestampColumnInfo, createTimestampColumnInfo);
+
+    expectUpdateHostComponentDesiredStateTable();
+    expectUpdateHostComponentStateTable();
+
+    Capture<DBColumnInfo> rvid = newCapture();
+    Capture<DBColumnInfo> orchestration = newCapture();
+    expectUpdateUpgradeTable(rvid, orchestration);
+
+    Capture<List<DBAccessor.DBColumnInfo>> columns = newCapture();
+    expectCreateUpgradeHistoryTable(columns);
+
+    expectDropStaleTables();
+
+    replay(dbAccessor, configuration, connection, statement, resultSet);
+
+    Module module = new Module() {
+      @Override
+      public void configure(Binder binder) {
+        binder.bind(DBAccessor.class).toInstance(dbAccessor);
+        binder.bind(OsFamily.class).toInstance(osFamily);
+        binder.bind(EntityManager.class).toInstance(entityManager);
+        binder.bind(Configuration.class).toInstance(configuration);
+      }
+    };
+
+    Injector injector = Guice.createInjector(module);
+    UpgradeCatalog260 upgradeCatalog260 = injector.getInstance(UpgradeCatalog260.class);
+    upgradeCatalog260.executeDDLUpdates();
+
+    verify(dbAccessor);
+
+    verifyGetCurrentVersionID(scdcaptureKey, scdcaptureValue);
+    verifyUpdateServiceComponentDesiredStateTable(scdstadd1, scdstalter1, scdstadd2, scdstalter2);
+    verifyUpdateServiceDesiredStateTable(sdstadd, sdstalter);
+    verifyAddSelectedCollumsToClusterconfigTable(selectedColumnInfo, selectedmappingColumnInfo, selectedTimestampColumnInfo, createTimestampColumnInfo);
+    verifyUpdateUpgradeTable(rvid, orchestration);
+    verifyCreateUpgradeHistoryTable(columns);
+
+  }
+
+  public void expectDropStaleTables() throws SQLException {
+    dbAccessor.dropTable(eq(UpgradeCatalog260.CLUSTER_CONFIG_MAPPING_TABLE));
+    expectLastCall().once();
+    dbAccessor.dropTable(eq(UpgradeCatalog260.CLUSTER_VERSION_TABLE));
+    expectLastCall().once();
+    dbAccessor.dropTable(eq(UpgradeCatalog260.SERVICE_COMPONENT_HISTORY_TABLE));
+    expectLastCall().once();
+  }
+
+  public void verifyCreateUpgradeHistoryTable(Capture<List<DBColumnInfo>> columns) {
+    List<DBColumnInfo> columnsValue = columns.getValue();
+    Assert.assertEquals(columnsValue.size(), 6);
+
+    DBColumnInfo id = columnsValue.get(0);
+    Assert.assertEquals(UpgradeCatalog260.ID_COLUMN, id.getName());
+    Assert.assertEquals(Long.class, id.getType());
+    Assert.assertEquals(null, id.getLength());
+    Assert.assertEquals(null, id.getDefaultValue());
+    Assert.assertEquals(false, id.isNullable());
+
+    DBColumnInfo upgradeId = columnsValue.get(1);
+    Assert.assertEquals(UpgradeCatalog260.UPGRADE_ID_COLUMN, upgradeId.getName());
+    Assert.assertEquals(Long.class, upgradeId.getType());
+    Assert.assertEquals(null, upgradeId.getLength());
+    Assert.assertEquals(null, upgradeId.getDefaultValue());
+    Assert.assertEquals(false, upgradeId.isNullable());
+
+    DBColumnInfo serviceName = columnsValue.get(2);
+    Assert.assertEquals(UpgradeCatalog260.SERVICE_NAME_COLUMN, serviceName.getName());
+    Assert.assertEquals(String.class, serviceName.getType());
+    Assert.assertEquals(Integer.valueOf(255), serviceName.getLength());
+    Assert.assertEquals(null, serviceName.getDefaultValue());
+    Assert.assertEquals(false, serviceName.isNullable());
+
+    DBColumnInfo componentName = columnsValue.get(3);
+    Assert.assertEquals(UpgradeCatalog260.COMPONENT_NAME_COLUMN, componentName.getName());
+    Assert.assertEquals(String.class, componentName.getType());
+    Assert.assertEquals(Integer.valueOf(255), componentName.getLength());
+    Assert.assertEquals(null, componentName.getDefaultValue());
+    Assert.assertEquals(false, componentName.isNullable());
+
+    DBColumnInfo fromRepoID = columnsValue.get(4);
+    Assert.assertEquals(UpgradeCatalog260.FROM_REPO_VERSION_ID_COLUMN, fromRepoID.getName());
+    Assert.assertEquals(Long.class, fromRepoID.getType());
+    Assert.assertEquals(null, fromRepoID.getLength());
+    Assert.assertEquals(null, fromRepoID.getDefaultValue());
+    Assert.assertEquals(false, fromRepoID.isNullable());
+
+    DBColumnInfo targetRepoID = columnsValue.get(5);
+    Assert.assertEquals(UpgradeCatalog260.TARGET_REPO_VERSION_ID_COLUMN, targetRepoID.getName());
+    Assert.assertEquals(Long.class, targetRepoID.getType());
+    Assert.assertEquals(null, targetRepoID.getLength());
+    Assert.assertEquals(null, targetRepoID.getDefaultValue());
+    Assert.assertEquals(false, targetRepoID.isNullable());
+  }
+
+  public void expectCreateUpgradeHistoryTable(Capture<List<DBColumnInfo>> columns) throws SQLException {
+    dbAccessor.createTable(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), capture(columns));
+    expectLastCall().once();
+
+    dbAccessor.addPKConstraint(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), eq(UpgradeCatalog260.PK_UPGRADE_HIST), eq(UpgradeCatalog260.ID_COLUMN));
+    expectLastCall().once();
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_HIST_UPGRADE_ID), eq(UpgradeCatalog260.UPGRADE_ID_COLUMN), eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.UPGRADE_ID_COLUMN), eq(false));
+    expectLastCall().once();
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_HIST_FROM_REPO), eq(UpgradeCatalog260.FROM_REPO_VERSION_ID_COLUMN), eq(UpgradeCatalog260.REPO_VERSION_TABLE), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(false));
+    expectLastCall().once();
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_HIST_TARGET_REPO), eq(UpgradeCatalog260.TARGET_REPO_VERSION_ID_COLUMN), eq(UpgradeCatalog260.REPO_VERSION_TABLE), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(false));
+    expectLastCall().once();
+    dbAccessor.addUniqueConstraint(eq(UpgradeCatalog260.UPGRADE_HISTORY_TABLE), eq(UpgradeCatalog260.UQ_UPGRADE_HIST), eq(UpgradeCatalog260.UPGRADE_ID_COLUMN), eq(UpgradeCatalog260.COMPONENT_NAME_COLUMN), eq(UpgradeCatalog260.SERVICE_NAME_COLUMN));
+    expectLastCall().once();
+  }
+
+  public void verifyUpdateUpgradeTable(Capture<DBColumnInfo> rvid, Capture<DBColumnInfo> orchestration) {
+    DBColumnInfo rvidValue = rvid.getValue();
+    Assert.assertEquals(UpgradeCatalog260.REPO_VERSION_ID_COLUMN, rvidValue.getName());
+    Assert.assertEquals(Long.class, rvidValue.getType());
+    Assert.assertEquals(null, rvidValue.getLength());
+    Assert.assertEquals(null, rvidValue.getDefaultValue());
+    Assert.assertEquals(false, rvidValue.isNullable());
+
+    DBColumnInfo orchestrationValue = orchestration.getValue();
+    Assert.assertEquals(UpgradeCatalog260.ORCHESTRATION_COLUMN, orchestrationValue.getName());
+    Assert.assertEquals(String.class, orchestrationValue.getType());
+    Assert.assertEquals(Integer.valueOf(255), orchestrationValue.getLength());
+    Assert.assertEquals(UpgradeCatalog260.STANDARD, orchestrationValue.getDefaultValue());
+    Assert.assertEquals(false, orchestrationValue.isNullable());
+  }
+
+  public void expectUpdateUpgradeTable(Capture<DBColumnInfo> rvid, Capture<DBColumnInfo> orchestration) throws SQLException {
+    dbAccessor.clearTable(eq(UpgradeCatalog260.UPGRADE_TABLE));
+    expectLastCall().once();
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_FROM_REPO_ID));
+    expectLastCall().once();
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_TO_REPO_ID));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.FROM_REPO_VERSION_ID_COLUMN));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.TO_REPO_VERSION_ID_COLUMN));
+    expectLastCall().once();
+
+    dbAccessor.addColumn(eq(UpgradeCatalog260.UPGRADE_TABLE), capture(rvid));
+    expectLastCall().once();
+    dbAccessor.addColumn(eq(UpgradeCatalog260.UPGRADE_TABLE), capture(orchestration));
+    expectLastCall().once();
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.UPGRADE_TABLE), eq(UpgradeCatalog260.FK_UPGRADE_REPO_VERSION_ID), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(UpgradeCatalog260.REPO_VERSION_TABLE), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(false));
+    expectLastCall().once();
+  }
+
+  public void expectUpdateHostComponentStateTable() throws SQLException {
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.HOST_COMPONENT_STATE_TABLE), eq(UpgradeCatalog260.FK_HCS_CURRENT_STACK_ID));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.HOST_COMPONENT_STATE_TABLE), eq(UpgradeCatalog260.CURRENT_STACK_ID_COLUMN));
+    expectLastCall().once();
+  }
+
+  public void expectUpdateHostComponentDesiredStateTable() throws SQLException {
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.HOST_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.FK_HCDS_DESIRED_STACK_ID));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.HOST_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.DESIRED_STACK_ID_COLUMN));
+    expectLastCall().once();
+  }
+
+  public void verifyAddSelectedCollumsToClusterconfigTable(Capture<DBColumnInfo> selectedColumnInfo, Capture<DBColumnInfo> selectedmappingColumnInfo, Capture<DBColumnInfo> selectedTimestampColumnInfo, Capture<DBColumnInfo> createTimestampColumnInfo) {
+    DBColumnInfo selectedColumnInfoValue = selectedColumnInfo.getValue();
+    Assert.assertEquals(UpgradeCatalog260.SELECTED_COLUMN, selectedColumnInfoValue.getName());
+    Assert.assertEquals(Short.class, selectedColumnInfoValue.getType());
+    Assert.assertEquals(null, selectedColumnInfoValue.getLength());
+    Assert.assertEquals(0, selectedColumnInfoValue.getDefaultValue());
+    Assert.assertEquals(false, selectedColumnInfoValue.isNullable());
+
+    DBColumnInfo selectedmappingColumnInfoValue = selectedmappingColumnInfo.getValue();
+    Assert.assertEquals(UpgradeCatalog260.SELECTED_COLUMN, selectedmappingColumnInfoValue.getName());
+    Assert.assertEquals(Integer.class, selectedmappingColumnInfoValue.getType());
+    Assert.assertEquals(null, selectedmappingColumnInfoValue.getLength());
+    Assert.assertEquals(0, selectedmappingColumnInfoValue.getDefaultValue());
+    Assert.assertEquals(false, selectedmappingColumnInfoValue.isNullable());
+
+    DBColumnInfo selectedTimestampColumnInfoValue = selectedTimestampColumnInfo.getValue();
+    Assert.assertEquals(UpgradeCatalog260.SELECTED_TIMESTAMP_COLUMN, selectedTimestampColumnInfoValue.getName());
+    Assert.assertEquals(Long.class, selectedTimestampColumnInfoValue.getType());
+    Assert.assertEquals(null, selectedTimestampColumnInfoValue.getLength());
+    Assert.assertEquals(0, selectedTimestampColumnInfoValue.getDefaultValue());
+    Assert.assertEquals(false, selectedTimestampColumnInfoValue.isNullable());
+
+    DBColumnInfo createTimestampColumnInfoValue = createTimestampColumnInfo.getValue();
+    Assert.assertEquals(UpgradeCatalog260.CREATE_TIMESTAMP_COLUMN, createTimestampColumnInfoValue.getName());
+    Assert.assertEquals(Long.class, createTimestampColumnInfoValue.getType());
+    Assert.assertEquals(null, createTimestampColumnInfoValue.getLength());
+    Assert.assertEquals(null, createTimestampColumnInfoValue.getDefaultValue());
+    Assert.assertEquals(false, createTimestampColumnInfoValue.isNullable());
+  }
+
+  public void expectAddSelectedCollumsToClusterconfigTable(Capture<DBColumnInfo> selectedColumnInfo, Capture<DBColumnInfo> selectedmappingColumnInfo, Capture<DBColumnInfo> selectedTimestampColumnInfo, Capture<DBColumnInfo> createTimestampColumnInfo) throws SQLException {
+    dbAccessor.copyColumnToAnotherTable(eq(UpgradeCatalog260.CLUSTER_CONFIG_MAPPING_TABLE), capture(selectedmappingColumnInfo),
+        eq(UpgradeCatalog260.CLUSTER_ID_COLUMN), eq(UpgradeCatalog260.TYPE_NAME_COLUMN), eq(UpgradeCatalog260.VERSION_TAG_COLUMN), eq(UpgradeCatalog260.CLUSTER_CONFIG_TABLE), capture(selectedColumnInfo),
+        eq(UpgradeCatalog260.CLUSTER_ID_COLUMN), eq(UpgradeCatalog260.TYPE_NAME_COLUMN), eq(UpgradeCatalog260.VERSION_TAG_COLUMN), eq(UpgradeCatalog260.SELECTED_COLUMN), eq(UpgradeCatalog260.SELECTED), eq(0));
+    expectLastCall().once();
+
+    dbAccessor.copyColumnToAnotherTable(eq(UpgradeCatalog260.CLUSTER_CONFIG_MAPPING_TABLE), capture(createTimestampColumnInfo),
+        eq(UpgradeCatalog260.CLUSTER_ID_COLUMN), eq(UpgradeCatalog260.TYPE_NAME_COLUMN), eq(UpgradeCatalog260.VERSION_TAG_COLUMN), eq(UpgradeCatalog260.CLUSTER_CONFIG_TABLE), capture(selectedTimestampColumnInfo),
+        eq(UpgradeCatalog260.CLUSTER_ID_COLUMN), eq(UpgradeCatalog260.TYPE_NAME_COLUMN), eq(UpgradeCatalog260.VERSION_TAG_COLUMN), eq(UpgradeCatalog260.SELECTED_COLUMN), eq(UpgradeCatalog260.SELECTED), eq(0));
+    expectLastCall().once();
+  }
+
+  public void verifyUpdateServiceDesiredStateTable(Capture<DBColumnInfo> sdstadd, Capture<DBColumnInfo> sdstalter) {
+    DBColumnInfo sdstaddValue = sdstadd.getValue();
+    Assert.assertEquals(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN, sdstaddValue.getName());
+    Assert.assertEquals(1, sdstaddValue.getDefaultValue());
+    Assert.assertEquals(Long.class, sdstaddValue.getType());
+    Assert.assertEquals(false, sdstaddValue.isNullable());
+    Assert.assertEquals(null, sdstaddValue.getLength());
+
+    DBColumnInfo sdstalterValue = sdstalter.getValue();
+    Assert.assertEquals(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN, sdstalterValue.getName());
+    Assert.assertEquals(null, sdstalterValue.getDefaultValue());
+    Assert.assertEquals(Long.class, sdstalterValue.getType());
+    Assert.assertEquals(false, sdstalterValue.isNullable());
+    Assert.assertEquals(null, sdstalterValue.getLength());
+  }
+
+  public void expectUpdateServiceDesiredStateTable(Capture<DBColumnInfo> sdstadd, Capture<DBColumnInfo> sdstalter) throws SQLException {
+    dbAccessor.addColumn(eq(UpgradeCatalog260.SERVICE_DESIRED_STATE_TABLE), capture(sdstadd));
+    expectLastCall().once();
+    dbAccessor.alterColumn(eq(UpgradeCatalog260.SERVICE_DESIRED_STATE_TABLE), capture(sdstalter));
+    expectLastCall().once();
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.SERVICE_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.FK_REPO_VERSION_ID), eq(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN), eq(UpgradeCatalog260.REPO_VERSION_TABLE), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(false));
+    expectLastCall().once();
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.SERVICE_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.FK_SDS_DESIRED_STACK_ID));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.SERVICE_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.DESIRED_STACK_ID_COLUMN));
+    expectLastCall().once();
+  }
+
+  public void verifyUpdateServiceComponentDesiredStateTable(Capture<DBColumnInfo> scdstadd1, Capture<DBColumnInfo> scdstalter1, Capture<DBColumnInfo> scdstadd2, Capture<DBColumnInfo> scdstalter2) {
+    DBColumnInfo scdstaddValue1 = scdstadd1.getValue();
+    Assert.assertEquals(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN, scdstaddValue1.getName());
+    Assert.assertEquals(1, scdstaddValue1.getDefaultValue());
+    Assert.assertEquals(Long.class, scdstaddValue1.getType());
+    Assert.assertEquals(false, scdstaddValue1.isNullable());
+
+    DBColumnInfo scdstalterValue1 = scdstalter1.getValue();
+    Assert.assertEquals(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN, scdstalterValue1.getName());
+    Assert.assertEquals(null, scdstalterValue1.getDefaultValue());
+    Assert.assertEquals(Long.class, scdstalterValue1.getType());
+    Assert.assertEquals(false, scdstalterValue1.isNullable());
+
+    DBColumnInfo scdstaddValue2 = scdstadd2.getValue();
+    Assert.assertEquals(UpgradeCatalog260.REPO_STATE_COLUMN, scdstaddValue2.getName());
+    Assert.assertEquals(UpgradeCatalog260.CURRENT, scdstaddValue2.getDefaultValue());
+    Assert.assertEquals(String.class, scdstaddValue2.getType());
+    Assert.assertEquals(false, scdstaddValue2.isNullable());
+    Assert.assertEquals(Integer.valueOf(255), scdstaddValue2.getLength());
+
+    DBColumnInfo scdstalterValue2 = scdstalter2.getValue();
+    Assert.assertEquals(UpgradeCatalog260.REPO_STATE_COLUMN, scdstalterValue2.getName());
+    Assert.assertEquals(UpgradeCatalog260.NOT_REQUIRED, scdstalterValue2.getDefaultValue());
+    Assert.assertEquals(String.class, scdstalterValue2.getType());
+    Assert.assertEquals(false, scdstalterValue2.isNullable());
+    Assert.assertEquals(Integer.valueOf(255), scdstaddValue2.getLength());
+  }
+
+  public void verifyGetCurrentVersionID(Capture<String[]> scdcaptureKey, Capture<String[]> scdcaptureValue) {
+    Assert.assertTrue(Arrays.equals(scdcaptureKey.getValue(), new String[]{UpgradeCatalog260.STATE_COLUMN}));
+    Assert.assertTrue(Arrays.equals(scdcaptureValue.getValue(), new String[]{UpgradeCatalog260.CURRENT}));
+  }
+
+  public void expectUpdateServiceComponentDesiredStateTable(Capture<DBColumnInfo> scdstadd1, Capture<DBColumnInfo> scdstalter1, Capture<DBColumnInfo> scdstadd2, Capture<DBColumnInfo> scdstalter2) throws SQLException {
+    dbAccessor.addColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(scdstadd1));
+    expectLastCall().once();
+
+    dbAccessor.alterColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(scdstalter1));
+    expectLastCall().once();
+
+    dbAccessor.addColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(scdstadd2));
+    expectLastCall().once();
+
+    dbAccessor.alterColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(scdstalter2));
+    expectLastCall().once();
+
+    dbAccessor.addFKConstraint(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.FK_SCDS_DESIRED_REPO_ID), eq(UpgradeCatalog260.DESIRED_REPO_VERSION_ID_COLUMN), eq(UpgradeCatalog260.REPO_VERSION_TABLE), eq(UpgradeCatalog260.REPO_VERSION_ID_COLUMN), eq(false));
+    expectLastCall().once();
+
+    dbAccessor.dropFKConstraint(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.FK_SCDS_DESIRED_STACK_ID));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.DESIRED_STACK_ID_COLUMN));
+    expectLastCall().once();
+    dbAccessor.dropColumn(eq(UpgradeCatalog260.SERVICE_COMPONENT_DESIRED_STATE_TABLE), eq(UpgradeCatalog260.DESIRED_VERSION_COLUMN));
+    expectLastCall().once();
+  }
+
+  public void expectGetCurrentVersionID(List<Integer> current, Capture<String[]> scdcaptureKey, Capture<String[]> scdcaptureValue) throws SQLException {
+    expect(dbAccessor.getIntColumnValues(eq("cluster_version"), eq("repo_version_id"),
+        capture(scdcaptureKey), capture(scdcaptureValue), eq(false))).andReturn(current).once();
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/dee7317e/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
index baae4c5..4de7e11 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
@@ -173,44 +173,19 @@ public class UpgradeCatalog300Test {
       }
     };
 
-    Capture<DBAccessor.DBColumnInfo> clusterConfigSelectedColumn = newCapture();
-    Capture<DBAccessor.DBColumnInfo> clusterConfigSelectedTimestampColumn = newCapture();
     Capture<DBAccessor.DBColumnInfo> hrcOpsDisplayNameColumn = newCapture();
-
-    dbAccessor.addColumn(eq(UpgradeCatalog300.CLUSTER_CONFIG_TABLE), capture(clusterConfigSelectedColumn));
-    dbAccessor.addColumn(eq(UpgradeCatalog300.CLUSTER_CONFIG_TABLE), capture(clusterConfigSelectedTimestampColumn));
     dbAccessor.addColumn(eq(UpgradeCatalog300.HOST_ROLE_COMMAND_TABLE), capture(hrcOpsDisplayNameColumn));
 
     dbAccessor.dropColumn(COMPONENT_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once();
     dbAccessor.dropColumn(COMPONENT_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once();
     dbAccessor.dropColumn(SERVICE_DESIRED_STATE_TABLE, SECURITY_STATE_COLUMN); expectLastCall().once();
 
-    // component table
-    Capture<DBAccessor.DBColumnInfo> componentStateColumn = newCapture();
-    dbAccessor.addColumn(eq(UpgradeCatalog300.COMPONENT_TABLE), capture(componentStateColumn));
-
     replay(dbAccessor, configuration);
 
     Injector injector = Guice.createInjector(module);
     UpgradeCatalog300 upgradeCatalog300 = injector.getInstance(UpgradeCatalog300.class);
     upgradeCatalog300.executeDDLUpdates();
 
-    DBAccessor.DBColumnInfo capturedSelectedColumn = clusterConfigSelectedColumn.getValue();
-    Assert.assertNotNull(capturedSelectedColumn);
-    Assert.assertEquals(UpgradeCatalog300.CLUSTER_CONFIG_SELECTED_COLUMN, capturedSelectedColumn.getName());
-    Assert.assertEquals(Short.class, capturedSelectedColumn.getType());
-
-    DBAccessor.DBColumnInfo capturedSelectedTimestampColumn = clusterConfigSelectedTimestampColumn.getValue();
-    Assert.assertNotNull(capturedSelectedTimestampColumn);
-    Assert.assertEquals(UpgradeCatalog300.CLUSTER_CONFIG_SELECTED_TIMESTAMP_COLUMN, capturedSelectedTimestampColumn.getName());
-    Assert.assertEquals(Long.class, capturedSelectedTimestampColumn.getType());
-
-    // component table
-    DBAccessor.DBColumnInfo capturedStateColumn = componentStateColumn.getValue();
-    Assert.assertNotNull(componentStateColumn);
-    Assert.assertEquals("repo_state", capturedStateColumn.getName());
-    Assert.assertEquals(String.class, capturedStateColumn.getType());
-
     DBAccessor.DBColumnInfo capturedOpsDisplayNameColumn = hrcOpsDisplayNameColumn.getValue();
     Assert.assertEquals(UpgradeCatalog300.HRC_OPS_DISPLAY_NAME_COLUMN, capturedOpsDisplayNameColumn.getName());
     Assert.assertEquals(null, capturedOpsDisplayNameColumn.getDefaultValue());
@@ -219,55 +194,6 @@ public class UpgradeCatalog300Test {
     verify(dbAccessor);
   }
 
-  /**
-   * Tests pre-DML executions.
-   *
-   * @throws Exception
-   */
-  @Test
-  public void testExecutePreDMLUpdates() throws Exception {
-    Module module = new Module() {
-      @Override
-      public void configure(Binder binder) {
-        binder.bind(DBAccessor.class).toInstance(dbAccessor);
-        binder.bind(OsFamily.class).toInstance(osFamily);
-        binder.bind(EntityManager.class).toInstance(entityManager);
-        binder.bind(Configuration.class).toInstance(configuration);
-      }
-    };
-
-    EntityManagerFactory emFactory = EasyMock.createNiceMock(EntityManagerFactory.class);
-    Cache emCache = EasyMock.createNiceMock(Cache.class);
-
-    expect(entityManager.getEntityManagerFactory()).andReturn(emFactory).atLeastOnce();
-    expect(emFactory.getCache()).andReturn(emCache).atLeastOnce();
-
-    EntityTransaction mockTransaction = EasyMock.createNiceMock(EntityTransaction.class);
-    Connection mockConnection = EasyMock.createNiceMock(Connection.class);
-    Statement mockStatement = EasyMock.createNiceMock(Statement.class);
-
-    expect(dbAccessor.getConnection()).andReturn(mockConnection).once();
-    expect(mockConnection.createStatement()).andReturn(mockStatement).once();
-
-    expect(mockStatement.executeQuery(EasyMock.anyString())).andReturn(
-        EasyMock.createNiceMock(ResultSet.class));
-
-    expect(entityManager.getTransaction()).andReturn(
-        mockTransaction).atLeastOnce();
-
-    dbAccessor.dropTable(UpgradeCatalog300.CLUSTER_CONFIG_MAPPING_TABLE);
-    EasyMock.expectLastCall().once();
-
-    replay(dbAccessor, entityManager, emFactory, emCache, mockConnection, mockTransaction,
-        mockStatement, configuration);
-
-    Injector injector = Guice.createInjector(module);
-    UpgradeCatalog300 upgradeCatalog300 = injector.getInstance(UpgradeCatalog300.class);
-    upgradeCatalog300.executePreDMLUpdates();
-
-    verify(dbAccessor, entityManager, emFactory, emCache);
-  }
-
   @Test
   public void testLogSearchUpdateConfigs() throws Exception {
     reset(clusters, cluster);


Mime
View raw message