The goal of this project is to help you generate checksum for your java migration using flyway.
There is a file checksum stored in the schema_version
table, but only for the .sql
You have to provide your own checksum for java files.
This plugin scans the db/migration folder looking for java migrations, and for each one, compute an md5sum and add it to the JavaMigrationChecksums
enum
Simply put this in your pom
<plugin>
<groupId>io.github.agileek</groupId>
<artifactId>java-checksum-flyway-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
This will generate a file ${project.build.directory}/generated-sources/io/github/agileek/flywayJavaMigrationChecksums
and you can use it in your java migrations
In your migration class, implement MigrationChecksumProvider
then
@Override
public Integer getChecksum() {
return JavaMigrationChecksums.valueOf(getClass().getSimpleName()).getChecksum();
}
The parameters are:
- location
- defaultValue = "/db/migration"
- locations
- defaultValue = "/db/migration"
- outputDirectory
- defaultValue = "${project.build.directory}/generated-sources"