In MigrateDB, runtime class path scanning has been replaced with build-time scanning.
This plugin provides the scanning capability for the Maven build system via the migratedb:scan
goal. A Gradle plugin is also available.
To scan the output of the current artifact when your migrations reside in db/migration
:
<plugin>
<groupId>de.unentscheidbar</groupId>
<artifactId>migratedb-maven-plugin</artifactId>
<version>0.3.0</version>
<executions>
<execution>
<goals>
<goal>scan</goal>
</goals>
</execution>
</executions>
</plugin>
A more complex example that uses non-default configuration options:
<plugin>
<groupId>de.unentscheidbar</groupId>
<artifactId>migratedb-maven-plugin</artifactId>
<version>0.3.0</version>
<executions>
<execution>
<goals>
<goal>scan</goal>
</goals>
<configuration>
<!-- Also scan the project dependencies for resources -->
<includeDependencies>true</includeDependencies>
<includes>
<!-- Our migrations live in these packages -->
<include>com/foo/myapp/persistence/sql/migration</include>
<include>com/foo/mylib/db/migrations</include>
</includes>
<followSymlinks>true</followSymlinks>
<outputDirectory>${/migratedb/classpath</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
For this example, the corresponding MigrateDB configuration would have to be tweaked to work with the changed output directory:
MigrateDb.configure()
.locations("classpath:migratedb/classpath")