@Override
  public void start() {
    DatabaseVersion.Status status = version.getStatus();
    if (status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
      throw MessageException.of("Database was upgraded to a more recent version of SonarQube. "
        + "A backup must probably be restored or the DB settings are incorrect.");
    }
    if (status == DatabaseVersion.Status.REQUIRES_UPGRADE) {
      Optional<Long> currentVersion = this.version.getVersion();
      if (currentVersion.isPresent() && currentVersion.get() < DatabaseVersion.MIN_UPGRADE_VERSION) {
        throw MessageException.of("The version of SonarQube you are trying to upgrade from is too old. Please upgrade to the " +
          MIN_UPGRADE_VERSION_HUMAN_READABLE + " Long-Term Active version first.");
      }

      String msg = "The database must be manually upgraded. Please backup the database and browse /setup. "
        + "For more information: https://docs.sonarsource.com/sonarqube/latest/setup/upgrading";
      LoggerFactory.getLogger(DatabaseServerCompatibility.class).warn(msg);
      Logger logger = LoggerFactory.getLogger(STARTUP_LOGGER_NAME);
      logger.warn(HIGHLIGHTER);
      logger.warn(msg);
      logger.warn(HIGHLIGHTER);
    }
  }
@Test
  public void log_warning_if_requires_upgrade() {
    DatabaseVersion version = mock(DatabaseVersion.class);
    when(version.getStatus()).thenReturn(DatabaseVersion.Status.REQUIRES_UPGRADE);
    when(version.getVersion()).thenReturn(Optional.of(DatabaseVersion.MIN_UPGRADE_VERSION));
    new DatabaseServerCompatibility(version).start();

    assertThat(logTester.logs()).hasSize(4);
    assertThat(logTester.logs(Level.WARN)).contains(
      "The database must be manually upgraded. Please backup the database and browse /setup. "
        + "For more information: https://docs.sonarsource.com/sonarqube/latest/setup/upgrading",
      "################################################################################",
      "The database must be manually upgraded. Please backup the database and browse /setup. "
        + "For more information: https://docs.sonarsource.com/sonarqube/latest/setup/upgrading",
      "################################################################################");
  }