From 80410997ecc21a6aace94887010b4f86e5160f78 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sat, 25 Apr 2020 09:30:58 +0200 Subject: [PATCH] Polish "Enhance Database initialization how to guide" See gh-21077 --- .../spring-boot-docs/src/main/asciidoc/howto.adoc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index 2e9a42c95b..fdda82eae6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1957,14 +1957,18 @@ For instance, if you want to always initialize the `DataSource` regardless of it ---- spring.datasource.initialization-mode=always ---- + In a JPA-based app, you can choose to let Hibernate create the schema or use `schema.sql`, but you cannot do both. Make sure to disable `spring.jpa.hibernate.ddl-auto` if you use `schema.sql`. + [indent=0,subs="verbatim,quotes,attributes"] ---- spring.jpa.hibernate.ddl-auto=none ---- + If you are using a <>, like Flyway or Liquibase, you cannot use basic SQL scripts to create and initialize the schema. -In this situation, if `schema.sql` and `data.sql` are present, they will be ignored. It is not possible to use a Database Migration Tool to manage schema creation, and a basic SQL script to initialize it. +In this situation, if `schema.sql` and `data.sql` are present, they will be ignored. +It is not possible to use a Database Migration Tool to manage schema creation, and a basic SQL script to initialize it. ==== By default, Spring Boot enables the fail-fast feature of the Spring JDBC initializer. @@ -2063,8 +2067,8 @@ To automatically run Liquibase database migrations on startup, add the `org.liqu [NOTE] ==== -When you add the `org.liquibase:liquibase-core` to your classpath, by default database migrations will run for both during application startup and before your tests run. -This behavior can be customized by using the configprop:spring.liquibase.enabled[] property, setting different values in the `main` and `test` folders. +When you add the `org.liquibase:liquibase-core` to your classpath, database migrations run by default for both during application startup and before your tests run. +This behavior can be customized by using the configprop:spring.liquibase.enabled[] property, setting different values in the `main` and `test` configurations. It is not possible to use two different ways to initialize the database (e.g. Liquibase for application startup, JPA for test runs). ====