review feedback
This commit is contained in:
parent
047fefce5e
commit
98d21c4ee3
|
@ -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();
|
||||
|
|
|
@ -145,7 +145,6 @@ public abstract class BaseTask<T extends BaseTask> {
|
|||
public abstract void execute() throws SQLException;
|
||||
|
||||
public String getFlywayVersion() {
|
||||
String retval = "";
|
||||
String releasePart = myProductVersion;
|
||||
if (releasePart.startsWith("V")) {
|
||||
releasePart = releasePart.substring(1);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RenameColumnTask extends BaseTableTask<RenameColumnTask> {
|
|||
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<RenameColumnTask> {
|
|||
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<RenameColumnTask> {
|
|||
|
||||
}
|
||||
|
||||
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<RenameColumnTask> {
|
|||
|
||||
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<RenameColumnTask> {
|
|||
.appendSuper(super.hashCode())
|
||||
.append(myOldName)
|
||||
.append(myNewName)
|
||||
.append(myAllowNeitherColumnToExist)
|
||||
.append(myIsOkayIfNeitherColumnExists)
|
||||
.append(myDeleteTargetColumnFirstIfBothExist)
|
||||
.toHashCode();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class HashTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkAllHashes() {
|
||||
public void testCheckAllHashes() {
|
||||
List<BaseTask<?>> tasks1 = new HapiFhirJpaMigrationTasks(Collections.emptySet()).getAllTasks(VersionEnum.values());
|
||||
Map<String, Integer> hashesByVersion = new HashMap<>();
|
||||
for (BaseTask task : tasks1) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue