Java Code Examples for org.flywaydb.core.api.configuration.FluentConfiguration#locations()

The following examples show how to use org.flywaydb.core.api.configuration.FluentConfiguration#locations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportDataConfiguration.java    From sbp with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.flyway", name = "import-data")
@DependsOn("flywayInitializer")
public FlywayDataImporter flywayDataImporter() {
    FluentConfiguration flywayConf = plugin != null
            ? Flyway.configure(plugin.getWrapper().getPluginClassLoader()) : Flyway.configure();
    flywayConf.configuration(flyway.getConfiguration());
    flywayConf.baselineVersion("0");
    flywayConf.baselineOnMigrate(true);
    flywayConf.locations("classpath:/db_data");
    flywayConf.table("_db_data");
    Flyway importDataFlyway = new Flyway(flywayConf);
    FlywayDataImporter importer = new FlywayDataImporter(importDataFlyway);
    importer.setOrder(Ordered.LOWEST_PRECEDENCE);
    return importer;
}
 
Example 2
Source File: CustomFlywayConfiguration.java    From nifi-registry with Apache License 2.0 6 votes vote down vote up
@Override
public void customize(final FluentConfiguration configuration) {
    final DatabaseType databaseType = getDatabaseType(configuration.getDataSource());
    LOGGER.info("Determined database type is {}", new Object[] {databaseType.name()});

    switch (databaseType) {
        case MYSQL:
            LOGGER.info("Setting migration locations to {}", new Object[] {LOCATIONS_MYSQL});
            configuration.locations(LOCATIONS_MYSQL);
            break;
        case POSTGRESQL:
            LOGGER.info("Setting migration locations to {}", new Object[] {LOCATIONS_POSTGRES});
            configuration.locations(LOCATIONS_POSTGRES);
            break;
        default:
            LOGGER.info("Setting migration locations to {}", new Object[] {LOCATIONS_DEFAULT});
            configuration.locations(LOCATIONS_DEFAULT);
            break;
    }
}
 
Example 3
Source File: FlywayCreator.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public Flyway createFlyway(DataSource dataSource) {
    FluentConfiguration configure = Flyway.configure();
    configure.dataSource(dataSource);
    if (flywayRuntimeConfig.connectRetries.isPresent()) {
        configure.connectRetries(flywayRuntimeConfig.connectRetries.getAsInt());
    }
    if (flywayRuntimeConfig.schemas.isPresent()) {
        configure.schemas(flywayRuntimeConfig.schemas.get().toArray(EMPTY_ARRAY));
    }
    if (flywayRuntimeConfig.table.isPresent()) {
        configure.table(flywayRuntimeConfig.table.get());
    }
    configure.locations(flywayBuildTimeConfig.locations.toArray(EMPTY_ARRAY));
    if (flywayRuntimeConfig.sqlMigrationPrefix.isPresent()) {
        configure.sqlMigrationPrefix(flywayRuntimeConfig.sqlMigrationPrefix.get());
    }
    if (flywayRuntimeConfig.repeatableSqlMigrationPrefix.isPresent()) {
        configure.repeatableSqlMigrationPrefix(flywayRuntimeConfig.repeatableSqlMigrationPrefix.get());
    }
    configure.baselineOnMigrate(flywayRuntimeConfig.baselineOnMigrate);
    configure.validateOnMigrate(flywayRuntimeConfig.validateOnMigrate);
    configure.outOfOrder(flywayRuntimeConfig.outOfOrder);
    if (flywayRuntimeConfig.baselineVersion.isPresent()) {
        configure.baselineVersion(flywayRuntimeConfig.baselineVersion.get());
    }
    if (flywayRuntimeConfig.baselineDescription.isPresent()) {
        configure.baselineDescription(flywayRuntimeConfig.baselineDescription.get());
    }
    configure.placeholders(flywayRuntimeConfig.placeholders);
    return configure.load();
}