Flyway

This module provides an very thin layer to use Spring Boot’s integration with Flyway

Configuration

Add the following dependency:

<dependency>
    <groupId>org.apache.isis.extensions</groupId>
    <artifactId>isis-extensions-flyway-impl</artifactId>
</dependency>

Also add the following module to your AppManifest:

@Configuration
@Import({
    ...
    IsisModuleExtFlywayImpl.class,
    ...
})
public static class AppManifest {
}

Also configure Flyway connection parameters to use those of JDO JDO/DataNucleus object store:

application.properties
spring.flyway.url=\
  ${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionURL}
spring.flyway.user=\
  ${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionUserName}
spring.flyway.password=\
  ${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionPassword}

If Flyway is enabled, then autoCreateAll should also be disabled:

application.properties
spring.flyway.enabled=true
isis.persistence.jdo-datanucleus.impl.datanucleus.schema.autoCreateAll=false

Using in-memory object stores

When running with an in-memory object store - either for prototyping or integration tests - you will need the database tables to be created first.

In normal circumstances this is most easily peformed using with autoCreateAll enabled (and Flyway disabled). If you want your tests to check your Flyway scripts beforehand, there is nothing to prevent you from using Flyway all the time, even for integration tests.

One point to be aware of though is that the DDL syntax may vary between an in-memory database (such as H2) and a typical production database (such as PostgreSQL or SQL Server). Luckily, Spring Boot’s Flyway integration allows different variants of scripts for different vendors to be stored, in db.migration.{vendor} package (where {vendor} is as defined by the DatabaseDriver class). The simpleapp starter app also provides an example of this.

Custom schemas

In some circumstances DataNucleus — when running with autoCreateAll enabled — has been known to not create the prerequisite schema objects.

If this occurs, consider enabling Flyway for in-memory tests, and then use a custom value of spring.flyway.locations property to pick up the custom schema files:

spring.flyway.locations=classpath:db/migration/custom-schema

This property could be configured for example using @TestPropertySource, or @ActiveProfile.

Reference