Skip to content

Commit

Permalink
Merge pull request #27096 from quarkusio/dependabot/maven/flyway.vers…
Browse files Browse the repository at this point in the history
…ion-9.1.0
  • Loading branch information
dependabot[bot] authored Aug 3, 2022
2 parents a2f82c0 + 3a7e63e commit 4fc2c32
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.0.10</jboss-logmanager.version>
<flyway.version>8.5.13</flyway.version>
<flyway.version>9.1.0</flyway.version>
<yasson.version>1.0.11</yasson.version>
<liquibase.version>4.14.0</liquibase.version>
<snakeyaml.version>1.30</snakeyaml.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.callback.Callback;
import org.flywaydb.core.api.migration.JavaMigration;
import org.flywaydb.core.extensibility.Plugin;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.logging.Logger;
Expand All @@ -51,6 +52,7 @@
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.logging.LoggingSetupBuildItem;
import io.quarkus.deployment.recording.RecorderContext;
import io.quarkus.flyway.runtime.FlywayBuildTimeConfig;
Expand Down Expand Up @@ -289,6 +291,11 @@ public NativeImageResourceBuildItem resources() {
return new NativeImageResourceBuildItem("org/flywaydb/database/version.txt");
}

@BuildStep
public ServiceProviderBuildItem flywayPlugins() {
return ServiceProviderBuildItem.allProvidersFromClassPath(Plugin.class.getName());
}

public static final class MigrationStateBuildItem extends SimpleBuildItem {

final Set<String> hasMigrations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ public Integer getChecksum() {
return null;
}

@Override
public boolean isUndo() {
return false;
}

@Override
public boolean canExecuteInTransaction() {
return true;
Expand All @@ -94,11 +89,6 @@ public void migrate(Context context) throws Exception {
statement.executeUpdate("INSERT INTO quarked_flyway VALUES (1002, 'test')");
}
}

@Override
public boolean isBaselineMigration() {
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ public Integer getChecksum() {
return null;
}

@Override
public boolean isUndo() {
return false;
}

@Override
public boolean canExecuteInTransaction() {
return true;
Expand All @@ -100,11 +95,6 @@ public void migrate(Context context) throws Exception {
statement.executeUpdate("INSERT INTO quarked_flyway VALUES (1002, 'test')");
}
}

@Override
public boolean isBaselineMigration() {
return false;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.quarkus.flyway.runtime;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.sql.DataSource;

Expand Down Expand Up @@ -57,8 +59,17 @@ public Flyway createFlyway(DataSource dataSource) {
configure.cleanDisabled(flywayRuntimeConfig.cleanDisabled);
configure.baselineOnMigrate(flywayRuntimeConfig.baselineOnMigrate);
configure.validateOnMigrate(flywayRuntimeConfig.validateOnMigrate);
configure.ignoreMissingMigrations(flywayRuntimeConfig.ignoreMissingMigrations);
configure.ignoreFutureMigrations(flywayRuntimeConfig.ignoreFutureMigrations);
configure.validateMigrationNaming(flywayRuntimeConfig.validateMigrationNaming);
List<String> patterns = new ArrayList<>(2);
//https://flywaydb.org/documentation/configuration/parameters/ignoreMigrationPatterns
if (flywayRuntimeConfig.ignoreMissingMigrations) {
patterns.add("*:Missing");
}
if (flywayRuntimeConfig.ignoreFutureMigrations) {
patterns.add("*:Future");
}
// Default is *:Future
configure.ignoreMigrationPatterns(patterns.toArray(new String[0]));
configure.cleanOnValidationError(flywayRuntimeConfig.cleanOnValidationError);
configure.outOfOrder(flywayRuntimeConfig.outOfOrder);
if (flywayRuntimeConfig.baselineVersion.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,11 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
*/
@ConfigItem
public Optional<String> initSql = Optional.empty();

/**
* Whether to validate migrations and callbacks whose scripts do not obey the correct naming convention. A failure can be
* useful to check that errors such as case sensitivity in migration prefixes have been corrected.
*/
@ConfigItem
public boolean validateMigrationNaming;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.configuration.Configuration;
import org.flywaydb.core.internal.util.ValidatePatternUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -200,23 +201,23 @@ void testOutOfOrder() {
void testIgnoreMissingMigrations() {
runtimeConfig.ignoreMissingMigrations = false;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertFalse(createdFlywayConfig().isIgnoreMissingMigrations());
assertFalse(ValidatePatternUtils.isMissingIgnored(createdFlywayConfig().getIgnoreMigrationPatterns()));

runtimeConfig.ignoreMissingMigrations = true;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertTrue(createdFlywayConfig().isIgnoreMissingMigrations());
assertTrue(ValidatePatternUtils.isMissingIgnored(createdFlywayConfig().getIgnoreMigrationPatterns()));
}

@Test
@DisplayName("ignoreFutureMigrations is correctly set")
void testIgnoreFutureMigrations() {
runtimeConfig.ignoreFutureMigrations = false;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertFalse(createdFlywayConfig().isIgnoreFutureMigrations());
assertFalse(ValidatePatternUtils.isFutureIgnored(createdFlywayConfig().getIgnoreMigrationPatterns()));

runtimeConfig.ignoreFutureMigrations = true;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertTrue(createdFlywayConfig().isIgnoreFutureMigrations());
assertTrue(ValidatePatternUtils.isFutureIgnored(createdFlywayConfig().getIgnoreMigrationPatterns()));
}

@Test
Expand Down Expand Up @@ -245,6 +246,18 @@ void testValidateOnMigrateOverwritten(final boolean input, final boolean expecte
assertEquals(runtimeConfig.validateOnMigrate, expected);
}

@Test
@DisplayName("validateMigrationNaming defaults to false and it is correctly set")
void testValidateMigrationNaming() {
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertEquals(runtimeConfig.validateMigrationNaming, createdFlywayConfig().isValidateMigrationNaming());
assertFalse(runtimeConfig.validateMigrationNaming);

runtimeConfig.validateMigrationNaming = true;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertTrue(createdFlywayConfig().isValidateMigrationNaming());
}

private static List<String> pathList(Location[] locations) {
return Stream.of(locations).map(Location::getPath).collect(Collectors.toList());
}
Expand Down

0 comments on commit 4fc2c32

Please sign in to comment.