diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java index 5d4acbf66e3..2bed73a9eeb 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java @@ -34,7 +34,7 @@ public class SchemaMigrator { public void validate() { if (mySkipValidation) { - ourLog.info("Database running in hibernate auto-update mode. Skipping schema validation."); + ourLog.warn("Database running in hibernate auto-update mode. Skipping schema validation."); return; } try (Connection connection = myDataSource.getConnection()) { @@ -52,7 +52,7 @@ public class SchemaMigrator { public void migrate() { if (mySkipValidation) { - ourLog.info("Database running in hibernate auto-update mode. Skipping schema migration."); + ourLog.warn("Database running in hibernate auto-update mode. Skipping schema migration."); return; } myMigrator.migrate(); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java index 45ab2b05c6c..cffe2dbb64c 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java @@ -145,7 +145,6 @@ public abstract class BaseTask { public abstract void execute() throws SQLException; public String getFlywayVersion() { - String retval = ""; String releasePart = myProductVersion; if (releasePart.startsWith("V")) { releasePart = releasePart.substring(1); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java index 42bdec9965d..5c21080ef43 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java @@ -37,7 +37,7 @@ public class RenameColumnTask extends BaseTableTask { private static final Logger ourLog = LoggerFactory.getLogger(RenameColumnTask.class); private String myOldName; private String myNewName; - private boolean myAllowNeitherColumnToExist; + private boolean myIsOkayIfNeitherColumnExists; private boolean myDeleteTargetColumnFirstIfBothExist; public RenameColumnTask(String theProductVersion, String theSchemaVersion) { @@ -89,7 +89,7 @@ public class RenameColumnTask extends BaseTableTask { throw new SQLException("Can not rename " + getTableName() + "." + myOldName + " to " + myNewName + " because both columns exist!"); } } else if (!haveOldName && !haveNewName) { - if (isAllowNeitherColumnToExist()) { + if (isOkayIfNeitherColumnExists()) { return; } throw new SQLException("Can not rename " + getTableName() + "." + myOldName + " to " + myNewName + " because neither column exists!"); @@ -128,12 +128,12 @@ public class RenameColumnTask extends BaseTableTask { } - public boolean isAllowNeitherColumnToExist() { - return myAllowNeitherColumnToExist; + public boolean isOkayIfNeitherColumnExists() { + return myIsOkayIfNeitherColumnExists; } - public void setAllowNeitherColumnToExist(boolean theAllowNeitherColumnToExist) { - myAllowNeitherColumnToExist = theAllowNeitherColumnToExist; + public void setOkayIfNeitherColumnExists(boolean theOkayIfNeitherColumnExists) { + myIsOkayIfNeitherColumnExists = theOkayIfNeitherColumnExists; } @Override @@ -146,7 +146,7 @@ public class RenameColumnTask extends BaseTableTask { return new EqualsBuilder() .appendSuper(super.equals(theO)) - .append(myAllowNeitherColumnToExist, that.myAllowNeitherColumnToExist) + .append(myIsOkayIfNeitherColumnExists, that.myIsOkayIfNeitherColumnExists) .append(myDeleteTargetColumnFirstIfBothExist, that.myDeleteTargetColumnFirstIfBothExist) .append(myOldName, that.myOldName) .append(myNewName, that.myNewName) @@ -159,7 +159,7 @@ public class RenameColumnTask extends BaseTableTask { .appendSuper(super.hashCode()) .append(myOldName) .append(myNewName) - .append(myAllowNeitherColumnToExist) + .append(myIsOkayIfNeitherColumnExists) .append(myDeleteTargetColumnFirstIfBothExist) .toHashCode(); } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java index a25812d697d..2ed866cdda4 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java @@ -176,16 +176,16 @@ public class Builder { /** * @param theOldName The old column name * @param theNewName The new column name - * @param theAllowNeitherColumnToExist Setting this to true means that it's not an error if neither column exists - * @param theDeleteTargetColumnFirstIfBothEixst Setting this to true causes the migrator to be ok with the target column existing. It will make sure that there is no data in the column with the new name, then delete it if so in order to make room for the renamed column. If there is data it will still bomb out. + * @param isOkayIfNeitherColumnExists Setting this to true means that it's not an error if neither column exists + * @param theDeleteTargetColumnFirstIfBothExist Setting this to true causes the migrator to be ok with the target column existing. It will make sure that there is no data in the column with the new name, then delete it if so in order to make room for the renamed column. If there is data it will still bomb out. */ - public BuilderWithTableName renameColumn(String theVersion, String theOldName, String theNewName, boolean theAllowNeitherColumnToExist, boolean theDeleteTargetColumnFirstIfBothEixst) { + public BuilderWithTableName renameColumn(String theVersion, String theOldName, String theNewName, boolean isOkayIfNeitherColumnExists, boolean theDeleteTargetColumnFirstIfBothExist) { RenameColumnTask task = new RenameColumnTask(myRelease, theVersion); task.setTableName(myTableName); task.setOldName(theOldName); task.setNewName(theNewName); - task.setAllowNeitherColumnToExist(theAllowNeitherColumnToExist); - task.setDeleteTargetColumnFirstIfBothExist(theDeleteTargetColumnFirstIfBothEixst); + task.setOkayIfNeitherColumnExists(isOkayIfNeitherColumnExists); + task.setDeleteTargetColumnFirstIfBothExist(theDeleteTargetColumnFirstIfBothExist); addTask(task); return this; } diff --git a/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/HashTest.java b/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/HashTest.java index 2a4949ea006..ffc5219726e 100644 --- a/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/HashTest.java +++ b/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/HashTest.java @@ -32,7 +32,7 @@ public class HashTest { } @Test - public void checkAllHashes() { + public void testCheckAllHashes() { List> tasks1 = new HapiFhirJpaMigrationTasks(Collections.emptySet()).getAllTasks(VersionEnum.values()); Map hashesByVersion = new HashMap<>(); for (BaseTask task : tasks1) { diff --git a/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTaskTest.java b/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTaskTest.java index 523231a8660..8c5accd2a67 100644 --- a/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTaskTest.java +++ b/hapi-fhir-jpaserver-migrate/src/test/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTaskTest.java @@ -112,7 +112,7 @@ public class RenameColumnTaskTest extends BaseTest { task.setTableName("SOMETABLE"); task.setOldName("myTextCol"); task.setNewName("TEXTCOL"); - task.setAllowNeitherColumnToExist(true); + task.setOkayIfNeitherColumnExists(true); getMigrator().addTask(task); getMigrator().migrate();