@Override
  void handle(Connection connection, DatabaseCharsetChecker.State state) throws SQLException {
    // PostgreSQL does not have concept of case-sensitive collation. Only charset ("encoding" in postgresql terminology)
    // must be verified.
    expectUtf8AsDefault(connection);

    if (state == DatabaseCharsetChecker.State.UPGRADE || state == DatabaseCharsetChecker.State.STARTUP) {
      // no need to check columns on fresh installs... as they are not supposed to exist!
      expectUtf8Columns(connection);
    }
  }
@Test
  public void upgrade_fails_if_non_utf8_column() throws Exception {
    // default charset is ok but two columns are not
    answerDefaultCharset("utf8");
    answerColumns(asList(
      new String[] {TABLE_ISSUES, COLUMN_KEE, "utf8"},
      new String[] {TABLE_PROJECTS, COLUMN_KEE, "latin"},
      new String[] {TABLE_PROJECTS, COLUMN_NAME, "latin"}));

    assertThatThrownBy(() -> underTest.handle(connection, DatabaseCharsetChecker.State.UPGRADE))
      .isInstanceOf(MessageException.class)
      .hasMessage("Database columns [projects.kee, projects.name] must have UTF8 charset.");
  }