AMBARI-21549. Ambari upgrade should update unique constraints (dlysnichenko)


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 9fe2b6788e198a47a2fcc2090810d16e683b5b48
Parents: 7ab5876
Author: Lisnichenko Dmitro <dlysniche...@hortonworks.com>
Authored: Mon Aug 14 14:50:04 2017 +0300
Committer: Lisnichenko Dmitro <dlysniche...@hortonworks.com>
Committed: Mon Aug 14 14:50:04 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ambari/server/orm/DBAccessor.java     | 10 ++++++++++
 .../java/org/apache/ambari/server/orm/DBAccessorImpl.java |  7 +++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9fe2b678/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 8f1a192..01bec59 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
@@ -184,6 +184,16 @@ public interface DBAccessor {
     throws SQLException;
 
   /**
+   * Add unique table constraint
+   * @param constraintName name of the constraint
+   * @param tableName name of the table
+   * @param columnNames list of columns
+   * @throws SQLException
+   */
+  void updateUniqueConstraint(String tableName, String constraintName, 
String... columnNames)
+      throws SQLException;
+
+  /**
    *
    * @param tableName name of the table
    * @param constraintName name of the constraint

http://git-wip-us.apache.org/repos/asf/ambari/blob/9fe2b678/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 d693809..bed21e8 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
@@ -571,6 +571,13 @@ public class DBAccessorImpl implements DBAccessor {
   }
 
   @Override
+  public void updateUniqueConstraint(String tableName, String constraintName, 
String... columnNames)
+      throws SQLException {
+    dropUniqueConstraint(tableName, constraintName);
+    addUniqueConstraint(tableName, constraintName, columnNames);
+  }
+
+  @Override
   public void addPKConstraint(String tableName, String constraintName, boolean 
ignoreErrors, String... columnName) throws SQLException {
     if (!tableHasPrimaryKey(tableName, null) && tableHasColumn(tableName, 
columnName)) {
       String query = dbmsHelper.getAddPrimaryKeyConstraintStatement(tableName, 
constraintName, columnName);

Reply via email to