@Override
  public boolean run() {
    try {
      String dbLocation =
          new File(config.getString(Configurator.DATABASE_LOCATION_PROPERTY_KEY)).getAbsolutePath();

      if (new CurrentDatabase(new StoreVersionCheck(new DefaultFileSystemAbstraction()))
          .storeFilesAtCurrentVersion(new File(dbLocation))) {
        return true;
      }

      File storeDir = new File(dbLocation);
      FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
      UpgradableDatabase upgradableDatabase =
          new UpgradableDatabase(new StoreVersionCheck(fileSystem));
      if (!upgradableDatabase.storeFilesUpgradeable(storeDir)) {
        return true;
      }

      try {
        new StoreMigrationTool()
            .run(
                dbLocation,
                configForStoreDir(new Config(dbConfig), storeDir),
                StringLogger.SYSTEM,
                monitor);
      } catch (UpgradeNotAllowedByConfigurationException e) {
        log.log(e.getMessage());
        System.out.println(e.getMessage());
        failureMessage = e.getMessage();
        return false;
      } catch (StoreUpgrader.UnableToUpgradeException e) {
        log.error("Unable to upgrade store", e);
        return false;
      }
      return true;
    } catch (Exception e) {
      log.error("Unknown error", e);
      return false;
    }
  }
  @Override
  public boolean needsMigration(File storeDir) throws IOException {
    if (upgradableDatabase.hasCurrentVersion(fileSystem, storeDir)) {
      return false;
    }

    switch (versionToUpgradeFrom(storeDir)) {
      case Legacy19Store.LEGACY_VERSION:
        return false;
      case Legacy20Store.LEGACY_VERSION:
      case Legacy21Store.LEGACY_VERSION:
        return true;
      default:
        throw new IllegalStateException(
            "Unknown version to upgrade from: " + versionToUpgradeFrom(storeDir));
    }
  }
 /**
  * Will detect which version we're upgrading from. Doing that initialization here is good because
  * we do this check when {@link #moveMigratedFiles(java.io.File, java.io.File) moving migrated
  * files}, which might be done as part of a resumed migration, i.e. run even if {@link
  * org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant#migrate(java.io.File,
  * java.io.File, SchemaIndexProvider, org.neo4j.io.pagecache.PageCache)} hasn't been run.
  */
 private String versionToUpgradeFrom(File storeDir) {
   if (versionToUpgradeFrom == null) {
     versionToUpgradeFrom = upgradableDatabase.checkUpgradeable(storeDir);
   }
   return versionToUpgradeFrom;
 }