/**
   * Perform sentry store schema upgrade
   *
   * @param fromSchemaVer Existing version of the sentry store. If null, then read from the sentry
   *     store
   * @throws SentryUserException
   */
  public void doUpgrade(String fromSchemaVer) throws SentryUserException {
    if (SentryStoreSchemaInfo.getSentrySchemaVersion().equals(fromSchemaVer)) {
      System.out.println("No schema upgrade required from version " + fromSchemaVer);
      return;
    }
    // Find the list of scripts to execute for this upgrade
    List<String> upgradeScripts = SentryStoreSchemaInfo.getUpgradeScripts(fromSchemaVer);
    testConnectionToMetastore();
    System.out.println(
        "Starting upgrade sentry store schema from version "
            + fromSchemaVer
            + " to "
            + SentryStoreSchemaInfo.getSentrySchemaVersion());
    String scriptDir = SentryStoreSchemaInfo.getSentryStoreScriptDir();
    try {
      for (String scriptFile : upgradeScripts) {
        System.out.println("Upgrade script " + scriptFile);
        if (!dryRun) {
          runBeeLine(scriptDir, scriptFile);
          System.out.println("Completed " + scriptFile);
        }
      }
    } catch (IOException eIO) {
      throw new SentryUserException(
          "Upgrade FAILED! Metastore state would be inconsistent !!", eIO);
    }

    // Revalidated the new version after upgrade
    verifySchemaVersion();
  }