Using Flyway for Database customization
pg-embedded
offers the FlywayPreparer that uses the Flyway Database migration framework for DDL preparation and database migration.
try (DatabaseManager manager = DatabaseManager.multiDatabases() .withInstancePreparer(EmbeddedPostgres.Builder::withDefaults) // apply all flyway migrations from the db/testing classpath location // to every database handed out by this manager .withDatabasePreparer(FlywayPreparer.forClasspathLocation("db/testing")) .build() .start()) { ... }
The FlywayPreparer is customizable by using the FlywayPreparer.addCustomizer()
and FlywayPreparer.addCustomizers()
methods which can augment the Flyway FluentConfiguration
instance that is used to create the Flyway
migrator.