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
a6bcc6f5
Commit
a6bcc6f5
authored
Apr 21, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Liquibase and Flyway docs and test other changelog formats
Closes gh-5741
parent
b159bb8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
9 deletions
+84
-9
LiquibaseAutoConfigurationTests.java
...oconfigure/liquibase/LiquibaseAutoConfigurationTests.java
+28
-1
db.changelog-override.json
...rc/test/resources/db/changelog/db.changelog-override.json
+39
-0
db.changelog-override.sql
...src/test/resources/db/changelog/db.changelog-override.sql
+8
-0
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+9
-8
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
View file @
a6bcc6f5
...
...
@@ -42,6 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link LiquibaseAutoConfiguration}.
*
* @author Marcel Overdijk
* @author Andy Wilkinson
*/
public
class
LiquibaseAutoConfigurationTests
{
...
...
@@ -90,7 +91,7 @@ public class LiquibaseAutoConfigurationTests {
}
@Test
public
void
test
Override
ChangeLog
()
throws
Exception
{
public
void
test
Xml
ChangeLog
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.xml"
);
this
.
context
.
register
(
EmbeddedDataSourceConfiguration
.
class
,
...
...
@@ -102,6 +103,32 @@ public class LiquibaseAutoConfigurationTests {
.
isEqualTo
(
"classpath:/db/changelog/db.changelog-override.xml"
);
}
@Test
public
void
testJsonChangeLog
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.json"
);
this
.
context
.
register
(
EmbeddedDataSourceConfiguration
.
class
,
LiquibaseAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
SpringLiquibase
liquibase
=
this
.
context
.
getBean
(
SpringLiquibase
.
class
);
assertThat
(
liquibase
.
getChangeLog
())
.
isEqualTo
(
"classpath:/db/changelog/db.changelog-override.json"
);
}
@Test
public
void
testSqlChangeLog
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"liquibase.change-log:classpath:/db/changelog/db.changelog-override.sql"
);
this
.
context
.
register
(
EmbeddedDataSourceConfiguration
.
class
,
LiquibaseAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
SpringLiquibase
liquibase
=
this
.
context
.
getBean
(
SpringLiquibase
.
class
);
assertThat
(
liquibase
.
getChangeLog
())
.
isEqualTo
(
"classpath:/db/changelog/db.changelog-override.sql"
);
}
@Test
public
void
testOverrideContexts
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
...
...
spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json
0 → 100644
View file @
a6bcc6f5
{
"databaseChangeLog"
:
[
{
"changeSet"
:
{
"author"
:
"awilkinson"
,
"id"
:
"1"
,
"changes"
:
[
{
"createTable"
:
{
"tableName"
:
"customer"
,
"columns"
:
[
{
"column"
:
{
"name"
:
"id"
,
"type"
:
"int"
,
"autoIncrement"
:
true
,
"constraints"
:
{
"nullable"
:
false
,
"primaryKey"
:
true
},
}
},
{
"column"
:
{
"name"
:
"name"
,
"type"
:
"varchar(50)"
,
"constraints"
:
{
"nullable"
:
false
}
}
}
],
}
}
]
}
}
]
}
spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql
0 → 100644
View file @
a6bcc6f5
--liquibase formatted sql
--changeset author:awilkinson
CREATE
TABLE
customer
(
id
int
AUTO_INCREMENT
NOT
NULL
PRIMARY
KEY
,
name
varchar
(
50
)
NOT
NULL
);
\ No newline at end of file
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
a6bcc6f5
...
...
@@ -1847,11 +1847,9 @@ initialization explicitly using `spring.batch.initializer.enabled=false`.
[[howto-use-a-higher-level-database-migration-tool]]
=== Use a higher level database migration tool
Spring Boot works fine with higher level migration tools http://flywaydb.org/[Flyway]
(SQL-based) and http://www.liquibase.org/[Liquibase] (XML). In general we prefer
Flyway because it is easier on the eyes, and it isn't very common to need platform
independence: usually only one or at most couple of platforms is needed.
=== Use a higher-level database migration tool
Spring Boot supports two higher-level migration tools: http://flywaydb.org/[Flyway]
and http://www.liquibase.org/[Liquibase].
[[howto-execute-flyway-database-migrations-on-startup]]
==== Execute Flyway database migrations on startup
...
...
@@ -1890,12 +1888,15 @@ To automatically run Liquibase database migrations on startup, add the
`org.liquibase:liquibase-core` to your classpath.
The master change log is by default read from `db/changelog/db.changelog-master.yaml` but
can be set using `liquibase.change-log`. See
can be set using `liquibase.change-log`. In addition to YAML, Liquibase also supports
JSON, XML, and SQL change log formats.
See
{sc-spring-boot-autoconfigure}/liquibase/LiquibaseProperties.{sc-ext}[`LiquibaseProperties`]
for details of available settings like contexts, default schema etc.
There is a {github-code}/spring-boot-samples/spring-boot-sample-liquibase[Liquibase sample]
so
you can see how to set things up.
There is a {github-code}/spring-boot-samples/spring-boot-sample-liquibase[Liquibase sample]
so
you can see how to set things up.
...
...
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