Repository: nifi-registry Updated Branches: refs/heads/master 44bc4adb1 -> f82757e31
NIFIREG-173 Improving logic for detecting existence of legacy database This closes #122. Signed-off-by: Kevin Doran <kdo...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/f82757e3 Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/f82757e3 Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/f82757e3 Branch: refs/heads/master Commit: f82757e31867549681d98623eb6bda06efb56427 Parents: 44bc4ad Author: Bryan Bende <bbe...@apache.org> Authored: Wed Jun 6 15:31:33 2018 -0400 Committer: Kevin Doran <kdo...@apache.org> Committed: Wed Jun 6 15:57:35 2018 -0400 ---------------------------------------------------------------------- .../registry/db/CustomFlywayMigrationStrategy.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/f82757e3/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayMigrationStrategy.java ---------------------------------------------------------------------- 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.jdbc.core.JdbcTemplate; 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 @@ public class CustomFlywayMigrationStrategy implements FlywayMigrationStrategy { 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