private void createUserAuthenticationTable() throws SQLException {
    if (!usersTableUpgraded()) {
      final String temporaryTable = USER_AUTHENTICATION_TABLE + "_tmp";
      List<DBAccessor.DBColumnInfo> columns = new ArrayList<>();
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_USER_AUTHENTICATION_ID_COLUMN, Long.class, null, null, false));
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_USER_ID_COLUMN, Integer.class, null, null, false));
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_AUTHENTICATION_TYPE_COLUMN, String.class, 50, null, false));
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_AUTHENTICATION_KEY_COLUMN, String.class, 2048, null, true));
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_CREATE_TIME_COLUMN, Long.class, null, null, true));
      columns.add(new DBAccessor.DBColumnInfo(USER_AUTHENTICATION_UPDATE_TIME_COLUMN, Long.class, null, null, true));

      // Make sure the temporary table does not exist
      dbAccessor.dropTable(temporaryTable);

      // Create temporary table
      dbAccessor.createTable(temporaryTable, columns);

      dbAccessor.executeUpdate(
        "insert into " + temporaryTable +
          "(" + USER_AUTHENTICATION_USER_AUTHENTICATION_ID_COLUMN + ", " + USER_AUTHENTICATION_USER_ID_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_TYPE_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_KEY_COLUMN + ", " + USER_AUTHENTICATION_CREATE_TIME_COLUMN + ", " + USER_AUTHENTICATION_UPDATE_TIME_COLUMN + ")" +
          " select distinct" +
          "  u." + USERS_USER_ID_COLUMN + "," +
          "  t.min_user_id," +
          "  u." + USERS_USER_TYPE_COLUMN + "," +
          "  u." + USERS_USER_PASSWORD_COLUMN + "," +
          "  u." + USERS_CREATE_TIME_COLUMN + "," +
          "  u." + USERS_CREATE_TIME_COLUMN +
          " from " + USERS_TABLE + " u inner join" +
          "   (select" +
          "     lower(" + USERS_USER_NAME_COLUMN + ") as " + USERS_USER_NAME_COLUMN + "," +
          "     min(" + USERS_USER_ID_COLUMN + ") as min_user_id" +
          "    from " + USERS_TABLE +
          "    group by lower(" + USERS_USER_NAME_COLUMN + ")) t" +
          " on (lower(u." + USERS_USER_NAME_COLUMN + ") = lower(t." + USERS_USER_NAME_COLUMN + "))"
      );

      // Ensure only LOCAL users have keys set in the user_authentication table
      dbAccessor.executeUpdate("update " + temporaryTable +
        " set " + USER_AUTHENTICATION_AUTHENTICATION_KEY_COLUMN + "=null" +
        " where " + USER_AUTHENTICATION_AUTHENTICATION_TYPE_COLUMN + "!='" + UserAuthenticationType.LOCAL.name() + "'");

      dbAccessor.createTable(USER_AUTHENTICATION_TABLE, columns);
      dbAccessor.addPKConstraint(USER_AUTHENTICATION_TABLE, USER_AUTHENTICATION_PRIMARY_KEY, USER_AUTHENTICATION_USER_AUTHENTICATION_ID_COLUMN);
      dbAccessor.addFKConstraint(USER_AUTHENTICATION_TABLE, USER_AUTHENTICATION_USER_AUTHENTICATION_USERS_FOREIGN_KEY, USER_AUTHENTICATION_USER_ID_COLUMN, USERS_TABLE, USERS_USER_ID_COLUMN, false);

      dbAccessor.executeUpdate(
        "insert into " + USER_AUTHENTICATION_TABLE +
          "(" + USER_AUTHENTICATION_USER_AUTHENTICATION_ID_COLUMN + ", " + USER_AUTHENTICATION_USER_ID_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_TYPE_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_KEY_COLUMN + ", " + USER_AUTHENTICATION_CREATE_TIME_COLUMN + ", " + USER_AUTHENTICATION_UPDATE_TIME_COLUMN + ")" +
          " select " +
          USER_AUTHENTICATION_USER_AUTHENTICATION_ID_COLUMN + ", " + USER_AUTHENTICATION_USER_ID_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_TYPE_COLUMN + ", " + USER_AUTHENTICATION_AUTHENTICATION_KEY_COLUMN + ", " + USER_AUTHENTICATION_CREATE_TIME_COLUMN + ", " + USER_AUTHENTICATION_UPDATE_TIME_COLUMN +
          " from " + temporaryTable
      );

      // Delete the temporary table
      dbAccessor.dropTable(temporaryTable);
    }
  }
If the <code>users</code> table has not yet been migrated, create the <code>user_authentication</code>
table and generate relevant records for that table based on data in the <code>users</code> table.
<p>
The records in the new <code>user_authentication</code> table represent all of the types associated
with a given (case-insensitive) username.  If <code>UserA:LOCAL</code>, <code>usera:LOCAL</code> and
<code>usera:LDAP</code> exist in the original <code>users</code> table, three records will be created
in the <code>user_authentication</code> table: one for each t
to <code>Role1</code>, the three <code>adminprivilege</code> records will be merged into a single
record for <code>usera</code>.

@throws SQLException if an error occurs while executing SQL statements
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog270.java