Currently Spring Boot executes Flyway database migrations on application startup which has the same effect as the migrate
command. Also it provides some info about migrations through an actuator endpoint which contains the same information as the info
command.
Those are very useful features but sometimes we need to run other commands especially repair
or clean
but there is no easy way to do that other than using the flyway-maven-plugin
:
mvn -Dflyway.url=<theurl> -Dflyway.password=<thepass> -Dflyway.user=<username> flyway:repair
I can use a configuration file to store those arguments but since I've already provided the database URL and credentials (through application properties, environment variables or whatever) It would be nice if Spring Boot Maven Plugin provides a goal to run other flyway commands:
mvn spring-boot:flyway-repair
If the plugin could use those already available information in the environment, then there is no need to pass database URL and credentials in every mvn flyway:*
command or even create a brand new configuration file.
We don't have an easy way to access properties set in the Spring Environment
from the Maven plugin so this would be pretty hard for us to do. We'd also be duplicating the effort of the existing flayway-maven-plugin
which I don't think is a particularly good idea I'm afraid.
If you need to read the settings from a YAML configuration file this Maven plugin might be useful: https://github.com/aadnk/yaml-properties-plugin
I have used it on a project where I have QueryDSL generating mapping classes from a database schema via a Maven plugin and I didn't want to duplicate the config so I read it from the application.yml instead.
Just thought it might be of some use.
@roberthunt Thanks.
Most helpful comment
If you need to read the settings from a YAML configuration file this Maven plugin might be useful: https://github.com/aadnk/yaml-properties-plugin
I have used it on a project where I have QueryDSL generating mapping classes from a database schema via a Maven plugin and I didn't want to duplicate the config so I read it from the application.yml instead.
Just thought it might be of some use.