public void upgradeToCurrentVersion() {
    if (isInitialImport()) {
      initialImports.forEach(InitialImport::performInitialImport);
      versionProvider.writeLastVersion(getCurrentVersion());
    } else if (getLastVersion().get() < getCurrentVersion()) {
      List<VersionUpgrade> upgraders = new ArrayList<>(upgrades);
      Collections.sort(upgraders);

      upgraders
          .stream()
          .filter(upgrader -> upgrader.getVersion() > getLastVersion().get())
          .forEach(
              upgrader -> {
                log.info(
                    "Performing upgrade from version {} to {} using {}",
                    getLastVersion(),
                    upgrader.getVersion(),
                    upgrader.getClass().getSimpleName());
                upgrader.performUpgrade();
              });
      versionProvider.writeLastVersion(getCurrentVersion());
    } else {
      log.debug("no upgrade nessessary");
    }
  }
 public Optional<Integer> getLastVersion() {
   return versionProvider.getLastVersion();
 }
 public int getCurrentVersion() {
   return versionProvider.getCurrentVersion();
 }