From 4946fffac243d27781c652042ffc10cfe12bb433 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Sat, 14 Dec 2019 17:27:17 -0500 Subject: [PATCH] pass test --- .../ca/uhn/fhir/cli/BaseFlywayMigrateDatabaseCommand.java | 3 ++- .../main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 69e3c5c6c0b..5828bf897a7 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 @@ -47,6 +47,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand extends B public static final String NO_COLUMN_SHRINK = "no-column-shrink"; public static final String DONT_USE_FLYWAY = "dont-use-flyway"; public static final String OUT_OF_ORDER_PERMITTED = "out-of-order-permitted"; + public static final String SKIP_VERSIONS = "skip-versions"; private Set myFlags; private String myMigrationTableName; @@ -80,7 +81,6 @@ public abstract class BaseFlywayMigrateDatabaseCommand extends B Options retVal = new Options(); addOptionalOption(retVal, "r", "dry-run", false, "Log the SQL statements that would be executed but to not actually make any changes"); - addRequiredOption(retVal, "u", "url", "URL", "The JDBC database URL"); addRequiredOption(retVal, "n", "username", "Username", "The JDBC database username"); addRequiredOption(retVal, "p", "password", "Password", "The JDBC database password"); @@ -89,6 +89,7 @@ public abstract class BaseFlywayMigrateDatabaseCommand extends B addOptionalOption(retVal, null, DONT_USE_FLYWAY,false, "If this option is set, the migrator will not use FlywayDB for migration. This setting should only be used if you are trying to migrate a legacy database platform that is not supported by FlywayDB."); addOptionalOption(retVal, null, OUT_OF_ORDER_PERMITTED,false, "If this option is set, the migrator will permit migration tasks to be run out of order. It shouldn't be required in most cases, however may be the solution if you see the error message 'Detected resolved migration not applied to database'."); addOptionalOption(retVal, null, NO_COLUMN_SHRINK, false, "If this flag is set, the system will not attempt to reduce the length of columns. This is useful in environments with a lot of existing data, where shrinking a column can take a very long time."); + addOptionalOption(retVal, null, SKIP_VERSIONS, "Versions", "A comma separated list of schema versions to skip. E.g. 4_1_0.20191214.2,4_1_0.20191214.4\""); return retVal; } 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 7ff36d30761..3bd7210c75a 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,6 +34,11 @@ import java.sql.SQLException; import java.util.List; import java.util.Optional; import java.util.Properties; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.apache.commons.lang3.StringUtils.isBlank; public class SchemaMigrator { public static final String HAPI_FHIR_MIGRATION_TABLENAME = "FLY_HFJ_MIGRATION";