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
40e51021
Commit
40e51021
authored
Apr 06, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5535 from gazal-k/gh-1826
* gh-1826: Add Liquibase rollback file support
parents
f43123f2
3623eeda
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
LiquibaseAutoConfiguration.java
...t/autoconfigure/liquibase/LiquibaseAutoConfiguration.java
+1
-0
LiquibaseProperties.java
...ork/boot/autoconfigure/liquibase/LiquibaseProperties.java
+14
-0
LiquibaseAutoConfigurationTests.java
...oconfigure/liquibase/LiquibaseAutoConfigurationTests.java
+22
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java
View file @
40e51021
...
@@ -105,6 +105,7 @@ public class LiquibaseAutoConfiguration {
...
@@ -105,6 +105,7 @@ public class LiquibaseAutoConfiguration {
liquibase
.
setShouldRun
(
this
.
properties
.
isEnabled
());
liquibase
.
setShouldRun
(
this
.
properties
.
isEnabled
());
liquibase
.
setLabels
(
this
.
properties
.
getLabels
());
liquibase
.
setLabels
(
this
.
properties
.
getLabels
());
liquibase
.
setChangeLogParameters
(
this
.
properties
.
getParameters
());
liquibase
.
setChangeLogParameters
(
this
.
properties
.
getParameters
());
liquibase
.
setRollbackFile
(
this
.
properties
.
getRollbackFile
());
return
liquibase
;
return
liquibase
;
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java
View file @
40e51021
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
liquibase
;
package
org
.
springframework
.
boot
.
autoconfigure
.
liquibase
;
import
java.io.File
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
...
@@ -90,6 +91,11 @@ public class LiquibaseProperties {
...
@@ -90,6 +91,11 @@ public class LiquibaseProperties {
*/
*/
private
Map
<
String
,
String
>
parameters
;
private
Map
<
String
,
String
>
parameters
;
/**
* The file to which rollback SQL will be written when an update is performed.
*/
private
File
rollbackFile
;
public
String
getChangeLog
()
{
public
String
getChangeLog
()
{
return
this
.
changeLog
;
return
this
.
changeLog
;
}
}
...
@@ -178,4 +184,12 @@ public class LiquibaseProperties {
...
@@ -178,4 +184,12 @@ public class LiquibaseProperties {
this
.
parameters
=
parameters
;
this
.
parameters
=
parameters
;
}
}
public
File
getRollbackFile
()
{
return
this
.
rollbackFile
;
}
public
void
setRollbackFile
(
File
rollbackFile
)
{
this
.
rollbackFile
=
rollbackFile
;
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
View file @
40e51021
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
liquibase
;
package
org
.
springframework
.
boot
.
autoconfigure
.
liquibase
;
import
java.io.File
;
import
java.util.Map
;
import
java.util.Map
;
import
liquibase.integration.spring.SpringLiquibase
;
import
liquibase.integration.spring.SpringLiquibase
;
...
@@ -24,6 +25,7 @@ import org.junit.Before;
...
@@ -24,6 +25,7 @@ import org.junit.Before;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.TemporaryFolder
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.beans.factory.BeanCreationException
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
...
@@ -32,6 +34,7 @@ import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
...
@@ -32,6 +34,7 @@ import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -45,6 +48,9 @@ public class LiquibaseAutoConfigurationTests {
...
@@ -45,6 +48,9 @@ public class LiquibaseAutoConfigurationTests {
@Rule
@Rule
public
ExpectedException
expected
=
ExpectedException
.
none
();
public
ExpectedException
expected
=
ExpectedException
.
none
();
@Rule
public
TemporaryFolder
temp
=
new
TemporaryFolder
();
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
@Before
@Before
...
@@ -192,4 +198,20 @@ public class LiquibaseAutoConfigurationTests {
...
@@ -192,4 +198,20 @@ public class LiquibaseAutoConfigurationTests {
assertThat
(
parameters
.
get
(
"foo"
)).
isEqualTo
(
"bar"
);
assertThat
(
parameters
.
get
(
"foo"
)).
isEqualTo
(
"bar"
);
}
}
@Test
public
void
testRollbackFile
()
throws
Exception
{
File
file
=
this
.
temp
.
newFile
(
"rollback-file.sql"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"liquibase.rollbackFile:"
+
file
.
getAbsolutePath
());
this
.
context
.
register
(
EmbeddedDataSourceConfiguration
.
class
,
LiquibaseAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
SpringLiquibase
liquibase
=
this
.
context
.
getBean
(
SpringLiquibase
.
class
);
File
actualFile
=
(
File
)
ReflectionTestUtils
.
getField
(
liquibase
,
"rollbackFile"
);
assertThat
(
actualFile
).
isEqualTo
(
file
).
exists
();
String
content
=
new
String
(
FileCopyUtils
.
copyToByteArray
(
file
));
assertThat
(
content
).
contains
(
"DROP TABLE PUBLIC.customer;"
);
}
}
}
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