configurable table name

This commit is contained in:
Ken Stevens 2019-11-26 13:40:03 -05:00
parent 01ebe9ae8c
commit 8c7c4fc56f
2 changed files with 14 additions and 2 deletions

View File

@ -22,7 +22,6 @@ package ca.uhn.fhir.cli;
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
import ca.uhn.fhir.jpa.migrate.FlywayMigrator;
import ca.uhn.fhir.jpa.migrate.SchemaMigrator;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
@ -41,6 +40,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand<T extends Enum> extends B
public static final String MIGRATE_DATABASE = "migrate-database";
private Set<String> myFlags;
private String myMigrationTableName;
protected Set<String> getFlags() {
return myFlags;
@ -110,7 +110,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand<T extends Enum> extends B
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
FlywayMigrator migrator = new FlywayMigrator(SchemaMigrator.HAPI_FHIR_MIGRATION_TABLENAME);
FlywayMigrator migrator = new FlywayMigrator(myMigrationTableName);
migrator.setConnectionUrl(url);
migrator.setDriverType(driverType);
migrator.setUsername(username);
@ -123,4 +123,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand<T extends Enum> extends B
protected abstract void addTasks(FlywayMigrator theMigrator);
public void setMigrationTableName(String theMigrationTableName) {
myMigrationTableName = theMigrationTableName;
}
}

View File

@ -21,9 +21,12 @@ package ca.uhn.fhir.cli;
*/
import ca.uhn.fhir.jpa.migrate.FlywayMigrator;
import ca.uhn.fhir.jpa.migrate.SchemaMigrator;
import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask;
import ca.uhn.fhir.jpa.migrate.tasks.HapiFhirJpaMigrationTasks;
import ca.uhn.fhir.util.VersionEnum;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import java.util.Arrays;
import java.util.List;
@ -45,4 +48,10 @@ public class HapiFlywayMigrateDatabaseCommand extends BaseFlywayMigrateDatabaseC
List<BaseTask<?>> tasks = new HapiFhirJpaMigrationTasks(getFlags()).getAllTasks(VersionEnum.values());
theMigrator.addTasks(tasks);
}
@Override
public void run(CommandLine theCommandLine) throws ParseException {
setMigrationTableName(SchemaMigrator.HAPI_FHIR_MIGRATION_TABLENAME);
super.run(theCommandLine);
}
}