Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
1eac4d60
Commit
1eac4d60
authored
Jan 18, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support configuration of Flyway's Pro properties
Closes gh-14989
parent
d3541fa6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
206 additions
and
7 deletions
+206
-7
FlywayAutoConfiguration.java
...rk/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
+13
-0
FlywayProperties.java
...framework/boot/autoconfigure/flyway/FlywayProperties.java
+98
-1
FlywayAutoConfigurationTests.java
...ot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+90
-0
FlywayPropertiesTests.java
...work/boot/autoconfigure/flyway/FlywayPropertiesTests.java
+5
-6
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
View file @
1eac4d60
...
...
@@ -221,6 +221,19 @@ public class FlywayAutoConfiguration {
.
to
(
configuration:
:
skipDefaultResolvers
);
map
.
from
(
properties
.
isValidateOnMigrate
())
.
to
(
configuration:
:
validateOnMigrate
);
// Pro properties
map
.
from
(
properties
.
getBatch
()).
whenNonNull
().
to
(
configuration:
:
batch
);
map
.
from
(
properties
.
getDryRunOutput
()).
whenNonNull
()
.
to
(
configuration:
:
dryRunOutput
);
map
.
from
(
properties
.
getErrorOverrides
()).
whenNonNull
()
.
to
(
configuration:
:
errorOverrides
);
map
.
from
(
properties
.
getLicenseKey
()).
whenNonNull
()
.
to
(
configuration:
:
licenseKey
);
map
.
from
(
properties
.
getOracleSqlplus
()).
whenNonNull
()
.
to
(
configuration:
:
oracleSqlplus
);
map
.
from
(
properties
.
getStream
()).
whenNonNull
().
to
(
configuration:
:
stream
);
map
.
from
(
properties
.
getUndoSqlMigrationPrefix
()).
whenNonNull
()
.
to
(
configuration:
:
undoSqlMigrationPrefix
);
}
private
void
configureCallbacks
(
FluentConfiguration
configuration
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java
View file @
1eac4d60
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
flyway
;
import
java.io.File
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
...
...
@@ -224,6 +225,46 @@ public class FlywayProperties {
*/
private
boolean
validateOnMigrate
=
true
;
/**
* Whether to batch SQL statements when executing them. Requires Flyway Pro or Flyway
* Enterprise.
*/
private
Boolean
batch
=
null
;
/**
* File to which the SQL statements of a migration dry run should be output. Requires
* Flyway Pro or Flyway Enterprise.
*/
private
File
dryRunOutput
=
null
;
/**
* Rules for the built-in error handling to override specific SQL states and error
* codes. Requires Flyway Pro or Flyway Enterprise.
*/
private
String
[]
errorOverrides
;
/**
* Licence key for Flyway Pro or Flyway Enterprise.
*/
private
String
licenseKey
;
/**
* Whether to enable support for Oracle SQL*Plus commands. Requires Flyway Pro or
* Flyway Enterprise.
*/
private
Boolean
oracleSqlplus
=
null
;
/**
* Whether to stream SQL migrarions when executing them. Requires Flyway Pro or Flyway
* Enterprise.
*/
private
Boolean
stream
=
null
;
/**
* File name prefix for undo SQL migrations. Requires Flyway Pro or Flyway Enterprise.
*/
private
String
undoSqlMigrationPrefix
=
null
;
public
boolean
isEnabled
()
{
return
this
.
enabled
;
}
...
...
@@ -516,4 +557,60 @@ public class FlywayProperties {
this
.
validateOnMigrate
=
validateOnMigrate
;
}
public
Boolean
getBatch
()
{
return
this
.
batch
;
}
public
void
setBatch
(
Boolean
batch
)
{
this
.
batch
=
batch
;
}
public
File
getDryRunOutput
()
{
return
this
.
dryRunOutput
;
}
public
void
setDryRunOutput
(
File
dryRunOutput
)
{
this
.
dryRunOutput
=
dryRunOutput
;
}
public
String
[]
getErrorOverrides
()
{
return
this
.
errorOverrides
;
}
public
void
setErrorOverrides
(
String
[]
errorOverrides
)
{
this
.
errorOverrides
=
errorOverrides
;
}
public
String
getLicenseKey
()
{
return
this
.
licenseKey
;
}
public
void
setLicenseKey
(
String
licenseKey
)
{
this
.
licenseKey
=
licenseKey
;
}
public
Boolean
getOracleSqlplus
()
{
return
this
.
oracleSqlplus
;
}
public
void
setOracleSqlplus
(
Boolean
oracleSqlplus
)
{
this
.
oracleSqlplus
=
oracleSqlplus
;
}
public
Boolean
getStream
()
{
return
this
.
stream
;
}
public
void
setStream
(
Boolean
stream
)
{
this
.
stream
=
stream
;
}
public
String
getUndoSqlMigrationPrefix
()
{
return
this
.
undoSqlMigrationPrefix
;
}
public
void
setUndoSqlMigrationPrefix
(
String
undoSqlMigrationPrefix
)
{
this
.
undoSqlMigrationPrefix
=
undoSqlMigrationPrefix
;
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
View file @
1eac4d60
...
...
@@ -31,6 +31,7 @@ import org.flywaydb.core.api.callback.Callback;
import
org.flywaydb.core.api.callback.Context
;
import
org.flywaydb.core.api.callback.Event
;
import
org.flywaydb.core.api.callback.FlywayCallback
;
import
org.flywaydb.core.internal.license.FlywayProUpgradeRequiredException
;
import
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
;
import
org.junit.Test
;
import
org.mockito.InOrder
;
...
...
@@ -380,6 +381,95 @@ public class FlywayAutoConfigurationTests {
});
}
@Test
public
void
batchIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.batch=true"
).
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" batch "
);
});
}
@Test
public
void
dryRunOutputIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.dryRunOutput=dryrun.sql"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" dryRunOutput "
);
});
}
@Test
public
void
errorOverridesIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.errorOverrides=D12345"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" errorOverrides "
);
});
}
@Test
public
void
licenseKeyIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.license-key=<<secret>>"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" licenseKey "
);
});
}
@Test
public
void
oracleSqlplusIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.oracle-sqlplus=true"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" oracle.sqlplus "
);
});
}
@Test
public
void
streamIsCorrectlyMapped
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.stream=true"
).
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" stream "
);
});
}
@Test
public
void
undoSqlMigrationPrefix
()
{
this
.
contextRunner
.
withUserConfiguration
(
EmbeddedDataSourceConfiguration
.
class
)
.
withPropertyValues
(
"spring.flyway.undo-sql-migration-prefix=undo"
)
.
run
((
context
)
->
{
assertThat
(
context
).
hasFailed
();
Throwable
failure
=
context
.
getStartupFailure
();
assertThat
(
failure
).
hasRootCauseInstanceOf
(
FlywayProUpgradeRequiredException
.
class
);
assertThat
(
failure
).
hasMessageContaining
(
" undoSqlMigrationPrefix "
);
});
}
@Configuration
(
proxyBeanMethods
=
false
)
protected
static
class
FlywayDataSourceConfiguration
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayPropertiesTests.java
View file @
1eac4d60
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -127,11 +127,10 @@ public class FlywayPropertiesTests {
// Handled as initSql array
ignoreProperties
(
configuration
,
"initSql"
);
ignoreProperties
(
properties
,
"initSqls"
);
// Pro version only
ignoreProperties
(
configuration
,
"batch"
,
"dryRunOutput"
,
"dryRunOutputAsFile"
,
"dryRunOutputAsFileName"
,
"errorHandlers"
,
"errorHandlersAsClassNames"
,
"errorOverrides"
,
"licenseKey"
,
"oracleSqlplus"
,
"stream"
,
"undoSqlMigrationPrefix"
);
// Handled as dryRunOutput
ignoreProperties
(
configuration
,
"dryRunOutputAsFile"
,
"dryRunOutputAsFileName"
);
// Deprecated
ignoreProperties
(
configuration
,
"errorHandlers"
,
"errorHandlersAsClassNames"
);
List
<
String
>
configurationKeys
=
new
ArrayList
<>(
configuration
.
keySet
());
Collections
.
sort
(
configurationKeys
);
List
<
String
>
propertiesKeys
=
new
ArrayList
<>(
properties
.
keySet
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment