NIFIREG-173 Improving logic for detecting existence of legacy database
This closes #122.
Signed-off-by: Kevin Doran <kdoran@apache.org>
diff --git a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayMigrationStrategy.java b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayMigrationStrategy.java
index 376de6a..7748acf 100644
--- a/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayMigrationStrategy.java
+++ b/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayMigrationStrategy.java
@@ -35,6 +35,7 @@
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
+import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -67,9 +68,18 @@
LOGGER.info("Found existing database...");
}
- final boolean existingLegacyDatabase = !StringUtils.isBlank(properties.getLegacyDatabaseDirectory());
- if (existingLegacyDatabase) {
+ boolean existingLegacyDatabase = false;
+ if (!StringUtils.isBlank(properties.getLegacyDatabaseDirectory())) {
LOGGER.info("Found legacy database properties...");
+
+ final File legacyDatabaseFile = new File(properties.getLegacyDatabaseDirectory(), "nifi-registry.mv.db");
+ if (legacyDatabaseFile.exists()) {
+ LOGGER.info("Found legacy database file...");
+ existingLegacyDatabase = true;
+ } else {
+ LOGGER.info("Did not find legacy database file...");
+ existingLegacyDatabase = false;
+ }
}
// If newDatabase is true, then we need to run the Flyway migration first to create all the tables, then the data migration