I have Spring Boot application with Flyway.
I have following sql script:
src/main/resources/db/migration/V1__init.sql
but the script is not executed.
In application.properties
file I have:
spring.datasource.url = jdbc:mysql://localhost:3306/carorderprocess?useSSL=false
spring.datasource.username = root
spring.datasource.password = ...
spring.flyway.baselineOnMigrate = true
When I run application, in DB I only see:
mysql> select * from flyway_schema_history;
+----------------+---------+-----------------------+----------+-----------------------+----------+--------------+---------------------+----------------+---------+
| installed_rank | version | description | type | script | checksum | installed_by | installed_on | execution_time | success |
+----------------+---------+-----------------------+----------+-----------------------+----------+--------------+---------------------+----------------+---------+
| 1 | 1 | << Flyway Baseline >> | BASELINE | << Flyway Baseline >> | NULL | root | 2019-11-19 10:47:52 | 0 | 1 |
+----------------+---------+-----------------------+----------+-----------------------+----------+--------------+---------------------+----------------+---------+
So the script is not executed, why?
This script won't run, as the version of the filename provided is not higher than the greatest version stored in flyway_schema_history
table. There are two solutions you can do:
flyway_schema_history
table V2__init.sql
(recommended solution)Then simply restart your spring boot app, and changes should be applied out of the box
One note: 1st solution probably requires removal of spring.flyway.baselineOnMigrate = true
property. I would also consider if you really need it. What it does can be found here