Spring Flyway Support: Difference between revisions
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
{{External|https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-execute-flyway-database-migrations-on-startup}} | {{External|https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-execute-flyway-database-migrations-on-startup}} | ||
Flyway database migration is automatically triggered on startup if "org.flywaydb:flyway-core" dependency is present in the application's classpath. | Flyway database migration is automatically triggered on startup if "org.flywaydb:flyway-core" dependency is present in the application's classpath. | ||
Line 24: | Line 23: | ||
spring.flyway.locations=classpath:db/migration,filesystem:/opt/migration | spring.flyway.locations=classpath:db/migration,filesystem:/opt/migration | ||
The {vendor} placeholder is set according to the type of database. | The {vendor} placeholder is set according to the type of database. | ||
=Configuration= | |||
{{External|https://github.com/spring-projects/spring-boot/blob/v2.1.1.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java}} | |||
=Organizatorium= | =Organizatorium= |
Revision as of 21:16, 4 December 2018
Internal
Overview
TODO
- Understand how main/resource/db/migration/V1.0_init.sql drives schema creation with Spring Data JPA.
Database Migration on Startup
Flyway database migration is automatically triggered on startup if "org.flywaydb:flyway-core" dependency is present in the application's classpath.
The migration script naming convention is V<version>_<name>.sql where:
- <version> is an underscore separated version, such as "1" or "1_2".
The migration script default location is "classpath:db/migration[/{vendor}]", but it can be overridden with the "spring.flyway.locations" property, which should contain a comma-separated list of one or more classpath: or filesystem: locations.
spring.flyway.locations=classpath:db/migration,filesystem:/opt/migration
The {vendor} placeholder is set according to the type of database.
Configuration
Organizatorium
- Disable flyway support: