Package fr.ght1pc9kc.testy.jooq
Class WithFlywaySchemaHistory
java.lang.Object
fr.ght1pc9kc.testy.jooq.WithFlywaySchemaHistory
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
public final class WithFlywaySchemaHistory
extends Object
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback
Extension used to initialize a Flyway history in a database.
A table is created into a schema provided by
DatasourceExtension
.
History rows can be inserted with model FlywayVersion
.
Example of use with default flyway history table
private static final WithInMemoryDatasource wDataSource = WithInMemoryDatasource.builder()
.setCatalog("test_db")
.build();
private static final WithFlywaySchemaHistory wFlywayHistory = WithFlywaySchemaHistory.builder(wDataSource)
.addVersion(FlywayVersion.builder()
.version("1.0")
.script("V1_0__my_custom_script.sql")
.type(MigrationType.SQL)
.description("my custom script")
.checksum(1230145397)
.installedBy("test_db")
.installedOn(Instant.now())
.success(true)
.build)
.build();
@RegisterExtension
static final ChainedExtension chain = ChainedExtension.outer(wDataSource)
.append(wFlywayHistory)
.register();
A customized history table name can also be defined.
private static final WithInMemoryDatasource wDataSource = WithInMemoryDatasource.builder()
.setCatalog("test_db")
.build();
private static final WithFlywaySchemaHistory wFlywayHistory = WithFlywaySchemaHistory.builder(wDataSource)
.setTableName("my_custom_flyway_history")
.addVersion(FlywayVersion.builder()
.version("1.0")
.script("V1_0__my_custom_script.sql")
.type(MigrationType.SQL)
.description("my custom script")
.checksum(1230145397)
.installedBy("test_db")
.installedOn(Instant.now())
.success(true)
.build)
.build();
@RegisterExtension
static final ChainedExtension chain = ChainedExtension.outer(wDataSource)
.append(wFlywayHistory)
.register();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Builder class forWithFlywaySchemaHistory
extension. -
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeAll
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext extensionContext) builder
(DatasourceExtension datasourceExtension) Create a builder for this class.
-
Method Details
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
beforeAll
in interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) - Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
builder
public static WithFlywaySchemaHistory.WithFlywaySchemaHistoryBuilder builder(DatasourceExtension datasourceExtension) Create a builder for this class.- Parameters:
datasourceExtension
-DatasourceExtension
to get the schema where Flyway history table will be created.- Returns:
WithFlywaySchemaHistory.WithFlywaySchemaHistoryBuilder
.
-