From 8c7c4fc56f3d2acefc6b2a28ce02dc519527236f Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Tue, 26 Nov 2019 13:40:03 -0500 Subject: [PATCH] configurable table name --- .../uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java | 7 +++++-- .../uhn/fhir/cli/HapiFlywayMigrateDatabaseCommand.java | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java index 95d82fa305a..db2da8d25c5 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java @@ -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 extends B public static final String MIGRATE_DATABASE = "migrate-database"; private Set myFlags; + private String myMigrationTableName; protected Set getFlags() { return myFlags; @@ -110,7 +110,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand 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 extends B protected abstract void addTasks(FlywayMigrator theMigrator); + public void setMigrationTableName(String theMigrationTableName) { + myMigrationTableName = theMigrationTableName; + } } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommand.java index 9de06be32eb..33abbbb7b24 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiFlywayMigrateDatabaseCommand.java @@ -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> 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); + } }