Update Liquibase and Flyway docs and test other changelog formats
Closes gh-5741
This commit is contained in:
@@ -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 testOverrideChangeLog() throws Exception {
|
||||
public void testXmlChangeLog() 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,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
--changeset author:awilkinson
|
||||
|
||||
CREATE TABLE customer (
|
||||
id int AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||
name varchar(50) NOT NULL
|
||||
);
|
||||
@@ -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.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user