org.zapodot.junit.db.plugin.FlywayInitializer Maven / Gradle / Ivy
package org.zapodot.junit.db.plugin;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationVersion;
import org.flywaydb.core.api.configuration.Configuration;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zapodot.junit.db.internal.EmbeddedDataSource;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.util.Map;
/**
* Plugin for initializing in-memory database using Flyway.
*/
public class FlywayInitializer implements InitializationPlugin {
private final FluentConfiguration flywayConfiguration;
private static final Logger LOGGER = LoggerFactory.getLogger(FlywayInitializer.class);
public static class Builder {
private final FluentConfiguration fluentConfiguration = Flyway.configure();
public Builder() {
fluentConfiguration.encoding(StandardCharsets.UTF_8.name())
.target(MigrationVersion.LATEST);
}
public Builder withInstalledBy(final String installedBy) {
fluentConfiguration.installedBy(installedBy);
return this;
}
public Builder withAllowMixed() {
fluentConfiguration.mixed(true);
return this;
}
/**
* Starting with FlyWay 9 this requires teams
* @return builder instance
* @deprecated use #withIgnoreMigrationPatterns instead
*/
@Deprecated
public Builder withIgnoreMissingMigrations() {
return withIgnoreMigrationPatterns("repeatable:missing");
}
/**
* Allows setting the pattern for ignoring migratins
* @param patterns a
© 2015 - 2024 Weber Informatics LLC | Privacy Policy