You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/07/11 16:25:35 UTC

[02/50] [abbrv] ambari git commit: AMBARI-21397. Remove previous upgrades to allow schema change

AMBARI-21397. Remove previous upgrades to allow schema change


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

Branch: refs/heads/branch-2.5
Commit: 2b147ea66976181db82a82ec933b1186589de437
Parents: 4560821
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Jul 3 18:56:36 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Tue Jul 4 20:22:35 2017 +0200

----------------------------------------------------------------------
 .../apache/ambari/server/upgrade/UpgradeCatalog252.java  | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2b147ea6/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 fd26504..0ab8180 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
@@ -36,6 +36,11 @@ public class UpgradeCatalog252 extends AbstractUpgradeCatalog {
   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";
 
   /**
    * Constructor.
@@ -109,6 +114,12 @@ public class UpgradeCatalog252 extends AbstractUpgradeCatalog {
    * @throws SQLException
    */
   private void addRepositoryColumnsToUpgradeTable() throws SQLException {
+    dbAccessor.executeQuery(String.format("UPDATE %s SET %s = NULL", CLUSTERS_TABLE, UPGRADE_ID_COLUMN));
+    dbAccessor.executeQuery(String.format("DELETE FROM %s", SERVICE_COMPONENT_HISTORY_TABLE));
+    dbAccessor.executeQuery(String.format("DELETE FROM %s", UPGRADE_ITEM_TABLE));
+    dbAccessor.executeQuery(String.format("DELETE FROM %s", UPGRADE_GROUP_TABLE));
+    dbAccessor.executeQuery(String.format("DELETE FROM %s", UPGRADE_TABLE));
+
     dbAccessor.dropColumn(UPGRADE_TABLE, "to_version");
     dbAccessor.dropColumn(UPGRADE_TABLE, "from_version");