Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump flyway.version from 8.5.13 to 9.0.4 #27032

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
@@ -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());
}
Comment on lines +295 to +297
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this change is future-proof


public static final class MigrationStateBuildItem extends SimpleBuildItem {

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

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

@Override
public boolean canExecuteInTransaction() {
return true;
@@ -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
@@ -84,11 +84,6 @@ public Integer getChecksum() {
return null;
}

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

@Override
public boolean canExecuteInTransaction() {
return true;
@@ -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;

@@ -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()) {
Original file line number Diff line number Diff line change
@@ -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
@@ -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;
@@ -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
@@ -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());
}