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 TypeMethodDescriptionDeprecated.The default changed to true so this call actually does nothing.cleanAfter
(boolean cleanAfter) Drop all objects in the configured schemas using Flyway after the test finishes.void
cleanup
(DataSource ds, Handle handle) Run cleanup code after a test.static JdbiFlywayMigration
Returns an instance ofJdbiFlywayMigration
which can be configured and used as aJdbiExtensionInitializer
.void
initialize
(DataSource ds, Handle handle) Run initialization code before a test.Use Defaultdb/migration
Flyway 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 ofJdbiFlywayMigration
which can be configured and used as aJdbiExtensionInitializer
.@RegisterExtension public JdbiExtension extension = JdbiExtension.h2() .withInitializer(JdbiFlywayMigration.flywayMigration().withDefaultPath());
- Returns:
- A
JdbiFlywayMigration
instance.
-
withDefaultPath
Use Defaultdb/migration
Flyway 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
Deprecated.The default changed to true so this call actually does nothing.Will drop all objects in the configured schemas using Flyway after the test finishes.- Returns:
- The instance itself for chaining method calls.
-
cleanAfter
Drop all objects in the configured schemas using Flyway after the test finishes.- Parameters:
cleanAfter
- Set to false to avoid cleaning of the schema.- Returns:
- The instance itself for chaining method calls.
-
initialize
Description copied from interface:JdbiExtensionInitializer
Run initialization code before a test.- Specified by:
initialize
in interfaceJdbiExtensionInitializer
- Parameters:
ds
- A reference to the managedDataSource
which is controlled by aJdbiExtension
.handle
- The sharedHandle
which is returned fromJdbiExtension.getSharedHandle()
.- See Also:
-
cleanup
Description copied from interface:JdbiExtensionInitializer
Run cleanup code after a test.- Specified by:
cleanup
in interfaceJdbiExtensionInitializer
- Parameters:
ds
- A reference to the managedDataSource
which is controlled by aJdbiExtension
.handle
- The sharedHandle
which is returned fromJdbiExtension.getSharedHandle()
.
-