Skip to content

Commit f1bf80f

Browse files
vpavicwilkinsona
authored andcommitted
Upgrade to Flyway 9.0.1
See gh-31723
1 parent 7855888 commit f1bf80f

File tree

9 files changed

+23
-179
lines changed

9 files changed

+23
-179
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import javax.sql.DataSource;
2323

2424
import org.flywaydb.core.api.MigrationState;
25-
import org.flywaydb.core.api.MigrationType;
2625
import org.junit.jupiter.api.Test;
2726

2827
import org.springframework.boot.actuate.flyway.FlywayEndpoint;
@@ -77,10 +76,8 @@ private List<FieldDescriptor> migrationFieldDescriptors() {
7776
.optional(),
7877
fieldWithPath("state")
7978
.description("State of the migration. (" + describeEnumValues(MigrationState.class) + ")"),
80-
fieldWithPath("type")
81-
.description("Type of the migration. (" + describeEnumValues(MigrationType.class) + ")"),
82-
fieldWithPath("version").description("Version of the database after applying the migration, if any.")
83-
.optional());
79+
fieldWithPath("type").description("Type of the migration."), fieldWithPath("version")
80+
.description("Version of the database after applying the migration, if any.").optional());
8481
}
8582

8683
@Configuration(proxyBeanMethods = false)

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
2727
import org.flywaydb.core.Flyway;
2828
import org.flywaydb.core.api.MigrationInfo;
2929
import org.flywaydb.core.api.MigrationState;
30-
import org.flywaydb.core.api.MigrationType;
3130

3231
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
3332
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
@@ -136,7 +135,7 @@ public List<FlywayMigration> getMigrations() {
136135
*/
137136
public static final class FlywayMigration {
138137

139-
private final MigrationType type;
138+
private final String type;
140139

141140
private final Integer checksum;
142141

@@ -157,7 +156,7 @@ public static final class FlywayMigration {
157156
private final Integer executionTime;
158157

159158
private FlywayMigration(MigrationInfo info) {
160-
this.type = info.getType();
159+
this.type = info.getType().name();
161160
this.checksum = info.getChecksum();
162161
this.version = nullSafeToString(info.getVersion());
163162
this.description = info.getDescription();
@@ -177,7 +176,7 @@ private Instant nullSafeToInstant(Date date) {
177176
return (date != null) ? Instant.ofEpochMilli(date.getTime()) : null;
178177
}
179178

180-
public MigrationType getType() {
179+
public String getType() {
181180
return this.type;
182181
}
183182

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/flyway/FlywayEndpointTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ void whenFlywayHasBeenBaselinedFlywayReportIsProduced() {
6262
Map<String, FlywayDescriptor> flywayBeans = context.getBean(FlywayEndpoint.class).flywayBeans()
6363
.getContexts().get(context.getId()).getFlywayBeans();
6464
assertThat(flywayBeans).hasSize(1);
65-
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(3);
65+
assertThat(flywayBeans.values().iterator().next().getMigrations()).hasSize(4);
6666
});
6767
}
6868

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.flywaydb.core.api.callback.Callback;
3333
import org.flywaydb.core.api.configuration.FluentConfiguration;
3434
import org.flywaydb.core.api.migration.JavaMigration;
35-
import org.flywaydb.core.internal.plugin.PluginRegister;
3635
import org.flywaydb.database.sqlserver.SQLServerConfigurationExtension;
3736

3837
import org.springframework.beans.factory.ObjectProvider;
@@ -202,7 +201,6 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
202201
map.from(properties.isCleanDisabled()).to(configuration::cleanDisabled);
203202
map.from(properties.isCleanOnValidationError()).to(configuration::cleanOnValidationError);
204203
map.from(properties.isGroup()).to(configuration::group);
205-
configureIgnoredMigrations(configuration, properties, map);
206204
map.from(properties.isMixed()).to(configuration::mixed);
207205
map.from(properties.isOutOfOrder()).to(configuration::outOfOrder);
208206
map.from(properties.isSkipDefaultCallbacks()).to(configuration::skipDefaultCallbacks);
@@ -242,7 +240,8 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
242240
map.from(properties.getOutputQueryResults())
243241
.to((outputQueryResults) -> configuration.outputQueryResults(outputQueryResults));
244242
map.from(properties.getSqlServerKerberosLoginFile()).whenNonNull()
245-
.to(this::configureSqlServerKerberosLoginFile);
243+
.to((sqlServerKerberosLoginFile) -> configureSqlServerKerberosLoginFile(configuration,
244+
sqlServerKerberosLoginFile));
246245
// No method reference for compatibility with Flyway 6.x
247246
map.from(properties.getSkipExecutingMigrations())
248247
.to((skipExecutingMigrations) -> configuration.skipExecutingMigrations(skipExecutingMigrations));
@@ -253,18 +252,6 @@ private void configureProperties(FluentConfiguration configuration, FlywayProper
253252
// No method reference for compatibility with Flyway version < 7.9
254253
map.from(properties.getDetectEncoding())
255254
.to((detectEncoding) -> configuration.detectEncoding(detectEncoding));
256-
// No method reference for compatibility with Flyway version < 8.0
257-
map.from(properties.getBaselineMigrationPrefix())
258-
.to((baselineMigrationPrefix) -> configuration.baselineMigrationPrefix(baselineMigrationPrefix));
259-
}
260-
261-
@SuppressWarnings("deprecation")
262-
private void configureIgnoredMigrations(FluentConfiguration configuration, FlywayProperties properties,
263-
PropertyMapper map) {
264-
map.from(properties.isIgnoreMissingMigrations()).to(configuration::ignoreMissingMigrations);
265-
map.from(properties.isIgnoreIgnoredMigrations()).to(configuration::ignoreIgnoredMigrations);
266-
map.from(properties.isIgnorePendingMigrations()).to(configuration::ignorePendingMigrations);
267-
map.from(properties.isIgnoreFutureMigrations()).to(configuration::ignoreFutureMigrations);
268255
}
269256

270257
private void configureFailOnMissingLocations(FluentConfiguration configuration,
@@ -286,9 +273,11 @@ private void configureCreateSchemas(FluentConfiguration configuration, boolean c
286273
}
287274
}
288275

289-
private void configureSqlServerKerberosLoginFile(String sqlServerKerberosLoginFile) {
290-
SQLServerConfigurationExtension sqlServerConfigurationExtension = PluginRegister
276+
private void configureSqlServerKerberosLoginFile(FluentConfiguration configuration,
277+
String sqlServerKerberosLoginFile) {
278+
SQLServerConfigurationExtension sqlServerConfigurationExtension = configuration.getPluginRegister()
291279
.getPlugin(SQLServerConfigurationExtension.class);
280+
Assert.state(sqlServerConfigurationExtension != null, "Flyway SQL Server extension missing");
292281
sqlServerConfigurationExtension.setKerberosLoginFile(sqlServerKerberosLoginFile);
293282
}
294283

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.Map;
2929

3030
import org.springframework.boot.context.properties.ConfigurationProperties;
31-
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
3231
import org.springframework.boot.convert.DurationUnit;
3332

3433
/**
@@ -209,7 +208,7 @@ public class FlywayProperties {
209208
/**
210209
* Whether to disable cleaning of the database.
211210
*/
212-
private boolean cleanDisabled;
211+
private boolean cleanDisabled = true;
213212

214213
/**
215214
* Whether to automatically call clean when a validation error occurs.
@@ -222,30 +221,6 @@ public class FlywayProperties {
222221
*/
223222
private boolean group;
224223

225-
/**
226-
* Whether to ignore missing migrations when reading the schema history table.
227-
*/
228-
@Deprecated
229-
private boolean ignoreMissingMigrations;
230-
231-
/**
232-
* Whether to ignore ignored migrations when reading the schema history table.
233-
*/
234-
@Deprecated
235-
private boolean ignoreIgnoredMigrations;
236-
237-
/**
238-
* Whether to ignore pending migrations when reading the schema history table.
239-
*/
240-
@Deprecated
241-
private boolean ignorePendingMigrations;
242-
243-
/**
244-
* Whether to ignore future migrations when reading the schema history table.
245-
*/
246-
@Deprecated
247-
private boolean ignoreFutureMigrations = true;
248-
249224
/**
250225
* Whether to allow mixing transactional and non-transactional statements within the
251226
* same migration.
@@ -377,11 +352,6 @@ public class FlywayProperties {
377352
*/
378353
private Boolean detectEncoding;
379354

380-
/**
381-
* Filename prefix for baseline migrations. Requires Flyway Teams.
382-
*/
383-
private String baselineMigrationPrefix;
384-
385355
/**
386356
* Prefix of placeholders in migration scripts.
387357
*/
@@ -664,50 +634,6 @@ public void setGroup(boolean group) {
664634
this.group = group;
665635
}
666636

667-
@Deprecated
668-
@DeprecatedConfigurationProperty(replacement = "spring.flyway.ignore-migration-patterns")
669-
public boolean isIgnoreMissingMigrations() {
670-
return this.ignoreMissingMigrations;
671-
}
672-
673-
@Deprecated
674-
public void setIgnoreMissingMigrations(boolean ignoreMissingMigrations) {
675-
this.ignoreMissingMigrations = ignoreMissingMigrations;
676-
}
677-
678-
@Deprecated
679-
@DeprecatedConfigurationProperty(replacement = "spring.flyway.ignore-migration-patterns")
680-
public boolean isIgnoreIgnoredMigrations() {
681-
return this.ignoreIgnoredMigrations;
682-
}
683-
684-
@Deprecated
685-
public void setIgnoreIgnoredMigrations(boolean ignoreIgnoredMigrations) {
686-
this.ignoreIgnoredMigrations = ignoreIgnoredMigrations;
687-
}
688-
689-
@Deprecated
690-
@DeprecatedConfigurationProperty(replacement = "spring.flyway.ignore-migration-patterns")
691-
public boolean isIgnorePendingMigrations() {
692-
return this.ignorePendingMigrations;
693-
}
694-
695-
@Deprecated
696-
public void setIgnorePendingMigrations(boolean ignorePendingMigrations) {
697-
this.ignorePendingMigrations = ignorePendingMigrations;
698-
}
699-
700-
@Deprecated
701-
@DeprecatedConfigurationProperty(replacement = "spring.flyway.ignore-migration-patterns")
702-
public boolean isIgnoreFutureMigrations() {
703-
return this.ignoreFutureMigrations;
704-
}
705-
706-
@Deprecated
707-
public void setIgnoreFutureMigrations(boolean ignoreFutureMigrations) {
708-
this.ignoreFutureMigrations = ignoreFutureMigrations;
709-
}
710-
711637
public boolean isMixed() {
712638
return this.mixed;
713639
}
@@ -860,17 +786,6 @@ public void setOracleKerberosCacheFile(String oracleKerberosCacheFile) {
860786
this.oracleKerberosCacheFile = oracleKerberosCacheFile;
861787
}
862788

863-
@DeprecatedConfigurationProperty(replacement = "spring.flyway.kerberos-config-file")
864-
@Deprecated
865-
public String getOracleKerberosConfigFile() {
866-
return getKerberosConfigFile();
867-
}
868-
869-
@Deprecated
870-
public void setOracleKerberosConfigFile(String oracleKerberosConfigFile) {
871-
setKerberosConfigFile(oracleKerberosConfigFile);
872-
}
873-
874789
public Boolean getOutputQueryResults() {
875790
return this.outputQueryResults;
876791
}
@@ -911,14 +826,6 @@ public void setDetectEncoding(final Boolean detectEncoding) {
911826
this.detectEncoding = detectEncoding;
912827
}
913828

914-
public String getBaselineMigrationPrefix() {
915-
return this.baselineMigrationPrefix;
916-
}
917-
918-
public void setBaselineMigrationPrefix(String baselineMigrationPrefix) {
919-
this.baselineMigrationPrefix = baselineMigrationPrefix;
920-
}
921-
922829
public String getScriptPlaceholderPrefix() {
923830
return this.scriptPlaceholderPrefix;
924831
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/Flyway5xAutoConfigurationTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ public Integer getChecksum() {
103103
return 1;
104104
}
105105

106-
@Override
107-
public boolean isUndo() {
108-
return false;
109-
}
110-
111106
@Override
112107
public boolean canExecuteInTransaction() {
113108
return true;
@@ -118,11 +113,6 @@ public void migrate(org.flywaydb.core.api.migration.Context context) {
118113

119114
}
120115

121-
@Override
122-
public boolean isBaselineMigration() {
123-
return false;
124-
}
125-
126116
}
127117

128118
}

0 commit comments

Comments
 (0)