Package org.jdbi.v3.testing.junit5
Class JdbiFlywayMigration
java.lang.Object
org.jdbi.v3.testing.junit5.JdbiFlywayMigration
- All Implemented Interfaces:
JdbiExtensionInitializer
Use
Flyway to create a database schema and/or preload a database instance.-
Method Summary
Modifier and TypeMethodDescriptionWill drop all objects in the configured schemas using Flyway after the test finishes.voidcleanup(DataSource ds, Handle handle) Run cleanup code after a test.static JdbiFlywayMigrationReturns an instance ofJdbiFlywayMigrationwhich can be configured and used as aJdbiExtensionInitializer.voidinitialize(DataSource ds, Handle handle) Run initialization code before a test.Use Defaultdb/migrationFlyway schema migration location.Add a custom flyway migration path.Add custom flyway migration paths.withSchema(String schema) Add flyway migration schema.withSchemas(String... moreSchemas) Add flyway migration schemas.
-
Method Details
-
flywayMigration
Returns an instance ofJdbiFlywayMigrationwhich can be configured and used as aJdbiExtensionInitializer.@RegisterExtension public JdbiExtension extension = JdbiExtension.h2() .withInitializer(JdbiFlywayMigration.flywayMigration().withDefaultPath());- Returns:
- A
JdbiFlywayMigrationinstance.
-
withDefaultPath
Use Defaultdb/migrationFlyway schema migration location. Migration scripts must be on the classpath.- Returns:
- The instance itself for chaining method calls.
-
withPath
Add a custom flyway migration path.- Parameters:
migrationPath- The path to add. Must not be null.- Returns:
- The instance itself for chaining method calls.
-
withPaths
Add custom flyway migration paths.- Parameters:
migrationPaths- One or more paths to add. Must not be null.- Returns:
- The instance itself for chaining method calls.
-
withSchema
Add flyway migration schema.- Parameters:
schema- A schema to add. Must not be null.- Returns:
- The instance itself for chaining method calls.
-
withSchemas
Add flyway migration schemas.- Parameters:
moreSchemas- One or more schemas to add. Must not be null.- Returns:
- The instance itself for chaining method calls.
-
cleanAfter
Will drop all objects in the configured schemas using Flyway after the test finishes.- Returns:
- The instance itself for chaining method calls.
-
initialize
Description copied from interface:JdbiExtensionInitializerRun initialization code before a test.- Specified by:
initializein interfaceJdbiExtensionInitializer- Parameters:
ds- A reference to the managedDataSourcewhich is controlled by aJdbiExtension.handle- The sharedHandlewhich is returned fromJdbiExtension.getSharedHandle().- See Also:
-
cleanup
Description copied from interface:JdbiExtensionInitializerRun cleanup code after a test.- Specified by:
cleanupin interfaceJdbiExtensionInitializer- Parameters:
ds- A reference to the managedDataSourcewhich is controlled by aJdbiExtension.handle- The sharedHandlewhich is returned fromJdbiExtension.getSharedHandle().
-