private void migrateRepoData() throws SQLException {
    if(dbAccessor.tableHasColumn(REPO_VERSION_TABLE, REPO_VERSION_REPOSITORIES_COLUMN)) {
      int repoOsId = 0;
      int repoDefinitionId = 0;

      // Get a map of repo_version.id to repo_version.repositories
      Map<Long, String> repoVersionData = dbAccessor.getKeyToStringColumnMap(REPO_VERSION_TABLE,
          REPO_VERSION_REPO_VERSION_ID_COLUMN, REPO_VERSION_REPOSITORIES_COLUMN, null, null, true);

      if (repoVersionData != null) {
        // For each entry in the map, parse the repo_version.repositories data and created records in the new
        // repo_os, repo_definition, and repo_tabs tables...
        for (Map.Entry<Long, String> entry : repoVersionData.entrySet()) {
          Long repoVersionId = entry.getKey();
          String repositoriesJson = entry.getValue();

          if (!StringUtils.isEmpty(repositoriesJson)) {
            JsonArray rootJson = new JsonParser().parse(repositoriesJson).getAsJsonArray();

            if (rootJson != null) {
              for (JsonElement rootElement : rootJson) {
                // process each OS element
                JsonObject rootObject = rootElement.getAsJsonObject();

                if (rootObject != null) {
                  JsonPrimitive osType = rootObject.getAsJsonPrimitive("OperatingSystems/os_type");
                  JsonPrimitive ambariManaged = rootObject.getAsJsonPrimitive("OperatingSystems/ambari_managed_repositories");
                  String isAmbariManaged = ambariManaged == null ? "1" :  (ambariManaged.getAsBoolean() ? "1" : "0"); //the SQL script which creates the DB schema defaults to 1

                  JsonArray repositories = rootObject.getAsJsonArray("repositories");

                  dbAccessor.insertRowIfMissing(REPO_OS_TABLE,
                      new String[]{REPO_OS_ID_COLUMN, REPO_OS_REPO_VERSION_ID_COLUMN, REPO_OS_AMBARI_MANAGED_COLUMN, REPO_OS_FAMILY_COLUMN},
                      new String[]{String.valueOf(++repoOsId), String.valueOf(repoVersionId), isAmbariManaged, getFormattedJSONPrimitiveString(osType)},
                      false);

                  if (repositories != null) {
                    for (JsonElement repositoryElement : repositories) {
                      JsonObject repositoryObject = repositoryElement.getAsJsonObject();

                      if (repositoryObject != null) {
                        JsonPrimitive repoId = repositoryObject.getAsJsonPrimitive("Repositories/repo_id");
                        JsonPrimitive repoName = repositoryObject.getAsJsonPrimitive("Repositories/repo_name");
                        JsonPrimitive baseUrl = repositoryObject.getAsJsonPrimitive("Repositories/base_url");
                        JsonArray tags = repositoryObject.getAsJsonArray("Repositories/tags");

                        dbAccessor.insertRowIfMissing(REPO_DEFINITION_TABLE,
                            new String[]{REPO_DEFINITION_ID_COLUMN, REPO_DEFINITION_REPO_OS_ID_COLUMN,
                                REPO_DEFINITION_REPO_NAME_COLUMN, REPO_DEFINITION_REPO_ID_COLUMN, REPO_DEFINITION_BASE_URL_COLUMN},
                            new String[]{String.valueOf(++repoDefinitionId), String.valueOf(repoOsId),
                                getFormattedJSONPrimitiveString(repoName), getFormattedJSONPrimitiveString(repoId),
                                getFormattedJSONPrimitiveString(baseUrl)},
                            false);

                        if (tags != null) {
                          for (JsonElement tagsElement : tags) {
                            JsonPrimitive tag = tagsElement.getAsJsonPrimitive();

                            if (tag != null) {
                              dbAccessor.insertRowIfMissing(REPO_TAGS_TABLE,
                                  new String[]{REPO_TAGS_REPO_DEFINITION_ID_COLUMN, REPO_TAGS_TAG_COLUMN},
                                  new String[]{String.valueOf(repoDefinitionId), getFormattedJSONPrimitiveString(tag)},
                                  false);
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }

      // Add the relevant records in the ambari_sequence table
      // - repo_os_id_seq
      // - repo_definition_id_seq
      dbAccessor.insertRowIfMissing(AMBARI_SEQUENCES_TABLE,
          new String[]{AMBARI_SEQUENCES_SEQUENCE_NAME_COLUMN, AMBARI_SEQUENCES_SEQUENCE_VALUE_COLUMN},
          new String[]{"'repo_os_id_seq'", String.valueOf(++repoOsId)},
          false);
      dbAccessor.insertRowIfMissing(AMBARI_SEQUENCES_TABLE,
          new String[]{AMBARI_SEQUENCES_SEQUENCE_NAME_COLUMN, AMBARI_SEQUENCES_SEQUENCE_VALUE_COLUMN},
          new String[]{"'repo_definition_id_seq'", String.valueOf(++repoDefinitionId)},
          false);
    }
  }
Perform steps to move data from the old repo_version.repositories structure into new tables -
repo_os, repo_definition, repo_tags

@throws SQLException
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java