Spring Flyway Support: Difference between revisions
Jump to navigation
Jump to search
Line 28: | Line 28: | ||
Error creating bean with name 'flywayInitializer' defined in class path resource ...: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "public" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table. | Error creating bean with name 'flywayInitializer' defined in class path resource ...: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "public" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table. | ||
Schema history table can be initiated by setting "baselineOnMigrate" to true | Schema history table can be initiated by setting "baselineOnMigrate" to true: | ||
spring.flyway.baselineOnMigrate=true | |||
=Configuration= | =Configuration= |
Revision as of 21:28, 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".
- <name> ?
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.
Flyway requires a schema history table to drive migration off of. If the schema history table is not found, the migration fails with:
Error creating bean with name 'flywayInitializer' defined in class path resource ...: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "public" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
Schema history table can be initiated by setting "baselineOnMigrate" to true:
spring.flyway.baselineOnMigrate=true
Configuration
Organizatorium
- Disable flyway support: