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
a270c13d
Commit
a270c13d
authored
Mar 01, 2016
by
Eddú Meléndez
Committed by
Andy Wilkinson
Jan 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to Flyway 4.0
Closes gh-5344
parent
15639d39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
2 deletions
+53
-2
FlywayAutoConfiguration.java
...rk/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
+10
-1
FlywayAutoConfigurationTests.java
...ot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+42
-0
pom.xml
spring-boot-dependencies/pom.xml
+1
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java
View file @
a270c13d
...
@@ -26,6 +26,7 @@ import javax.sql.DataSource;
...
@@ -26,6 +26,7 @@ import javax.sql.DataSource;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.flywaydb.core.api.callback.FlywayCallback
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
...
@@ -61,6 +62,7 @@ import org.springframework.util.ObjectUtils;
...
@@ -61,6 +62,7 @@ import org.springframework.util.ObjectUtils;
* @author Vedran Pavic
* @author Vedran Pavic
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Jacques-Etienne Beaudet
* @author Jacques-Etienne Beaudet
* @author Eddú Meléndez
* @since 1.1.0
* @since 1.1.0
*/
*/
@Configuration
@Configuration
...
@@ -92,15 +94,19 @@ public class FlywayAutoConfiguration {
...
@@ -92,15 +94,19 @@ public class FlywayAutoConfiguration {
private
final
FlywayMigrationStrategy
migrationStrategy
;
private
final
FlywayMigrationStrategy
migrationStrategy
;
private
FlywayCallback
[]
flywayCallbacks
;
public
FlywayConfiguration
(
FlywayProperties
properties
,
public
FlywayConfiguration
(
FlywayProperties
properties
,
ResourceLoader
resourceLoader
,
ObjectProvider
<
DataSource
>
dataSource
,
ResourceLoader
resourceLoader
,
ObjectProvider
<
DataSource
>
dataSource
,
@FlywayDataSource
ObjectProvider
<
DataSource
>
flywayDataSource
,
@FlywayDataSource
ObjectProvider
<
DataSource
>
flywayDataSource
,
ObjectProvider
<
FlywayMigrationStrategy
>
migrationStrategy
)
{
ObjectProvider
<
FlywayMigrationStrategy
>
migrationStrategy
,
ObjectProvider
<
FlywayCallback
[]>
flywayCallbacks
)
{
this
.
properties
=
properties
;
this
.
properties
=
properties
;
this
.
resourceLoader
=
resourceLoader
;
this
.
resourceLoader
=
resourceLoader
;
this
.
dataSource
=
dataSource
.
getIfUnique
();
this
.
dataSource
=
dataSource
.
getIfUnique
();
this
.
flywayDataSource
=
flywayDataSource
.
getIfAvailable
();
this
.
flywayDataSource
=
flywayDataSource
.
getIfAvailable
();
this
.
migrationStrategy
=
migrationStrategy
.
getIfAvailable
();
this
.
migrationStrategy
=
migrationStrategy
.
getIfAvailable
();
this
.
flywayCallbacks
=
flywayCallbacks
.
getIfAvailable
();
}
}
@PostConstruct
@PostConstruct
...
@@ -140,6 +146,9 @@ public class FlywayAutoConfiguration {
...
@@ -140,6 +146,9 @@ public class FlywayAutoConfiguration {
else
{
else
{
flyway
.
setDataSource
(
this
.
dataSource
);
flyway
.
setDataSource
(
this
.
dataSource
);
}
}
if
(
this
.
flywayCallbacks
!=
null
&&
this
.
flywayCallbacks
.
length
>
0
)
{
flyway
.
setCallbacks
(
this
.
flywayCallbacks
);
}
flyway
.
setLocations
(
this
.
properties
.
getLocations
().
toArray
(
new
String
[
0
]));
flyway
.
setLocations
(
this
.
properties
.
getLocations
().
toArray
(
new
String
[
0
]));
return
flyway
;
return
flyway
;
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
View file @
a270c13d
...
@@ -25,6 +25,7 @@ import javax.sql.DataSource;
...
@@ -25,6 +25,7 @@ import javax.sql.DataSource;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.Flyway
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.flywaydb.core.api.MigrationVersion
;
import
org.flywaydb.core.api.callback.BaseFlywayCallback
;
import
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
;
import
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -57,6 +58,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -57,6 +58,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Phillip Webb
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Vedran Pavic
* @author Vedran Pavic
* @author Eddú Meléndez
*/
*/
public
class
FlywayAutoConfigurationTests
{
public
class
FlywayAutoConfigurationTests
{
...
@@ -202,6 +204,16 @@ public class FlywayAutoConfigurationTests {
...
@@ -202,6 +204,16 @@ public class FlywayAutoConfigurationTests {
assertThat
(
initializer
.
getOrder
()).
isEqualTo
(
Ordered
.
HIGHEST_PRECEDENCE
);
assertThat
(
initializer
.
getOrder
()).
isEqualTo
(
Ordered
.
HIGHEST_PRECEDENCE
);
}
}
@Test
public
void
customFlywayCallback
()
throws
Exception
{
registerAndRefresh
(
EmbeddedDataSourceConfiguration
.
class
,
FlywayAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
MockOneFlywayCallback
.
class
,
MockTwoFlywayCallback
.
class
);
assertThat
(
this
.
context
.
getBean
(
Flyway
.
class
)).
isNotNull
();
this
.
context
.
getBean
(
MockOneFlywayCallback
.
class
).
assertCalled
();
this
.
context
.
getBean
(
MockTwoFlywayCallback
.
class
).
assertCalled
();
}
@Test
@Test
public
void
customFlywayWithJpa
()
throws
Exception
{
public
void
customFlywayWithJpa
()
throws
Exception
{
registerAndRefresh
(
CustomFlywayWithJpaConfiguration
.
class
,
registerAndRefresh
(
CustomFlywayWithJpaConfiguration
.
class
,
...
@@ -325,4 +337,34 @@ public class FlywayAutoConfigurationTests {
...
@@ -325,4 +337,34 @@ public class FlywayAutoConfigurationTests {
}
}
@Component
protected
static
class
MockOneFlywayCallback
extends
BaseFlywayCallback
{
private
boolean
called
=
false
;
public
MockOneFlywayCallback
()
{
this
.
called
=
true
;
}
public
void
assertCalled
()
{
assertThat
(
this
.
called
).
isTrue
();
}
}
@Component
protected
static
class
MockTwoFlywayCallback
extends
BaseFlywayCallback
{
private
boolean
called
=
false
;
public
MockTwoFlywayCallback
()
{
this
.
called
=
true
;
}
public
void
assertCalled
()
{
assertThat
(
this
.
called
).
isTrue
();
}
}
}
}
spring-boot-dependencies/pom.xml
View file @
a270c13d
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
<ehcache.version>
2.10.3
</ehcache.version>
<ehcache.version>
2.10.3
</ehcache.version>
<ehcache3.version>
3.2.0
</ehcache3.version>
<ehcache3.version>
3.2.0
</ehcache3.version>
<embedded-mongo.version>
1.50.5
</embedded-mongo.version>
<embedded-mongo.version>
1.50.5
</embedded-mongo.version>
<flyway.version>
3.2.1
</flyway.version>
<flyway.version>
4.0.3
</flyway.version>
<freemarker.version>
2.3.25-incubating
</freemarker.version>
<freemarker.version>
2.3.25-incubating
</freemarker.version>
<elasticsearch.version>
2.4.4
</elasticsearch.version>
<elasticsearch.version>
2.4.4
</elasticsearch.version>
<glassfish-el.version>
3.0.0
</glassfish-el.version>
<glassfish-el.version>
3.0.0
</glassfish-el.version>
...
...
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