Search in sources :

Example 6 with Location

use of org.flywaydb.core.api.Location in project spring-boot by spring-projects.

the class Flyway7xAutoConfigurationTests method defaultFlyway.

@Test
void defaultFlyway() {
    this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/migration"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 7 with Location

use of org.flywaydb.core.api.Location in project dhis2-core by dhis2.

the class FlywayConfig method flyway.

@Bean(value = "flyway", initMethod = "migrate")
@Profile("!test-h2")
@DependsOn("dataSource")
public Flyway flyway(DhisConfigurationProvider configurationProvider, DataSource dataSource) {
    ClassicConfiguration classicConfiguration = new ClassicConfiguration();
    classicConfiguration.setDataSource(dataSource);
    classicConfiguration.setBaselineOnMigrate(true);
    classicConfiguration.setOutOfOrder(configurationProvider.isEnabled(FLYWAY_OUT_OF_ORDER_MIGRATION));
    classicConfiguration.setIgnoreMissingMigrations(true);
    classicConfiguration.setIgnoreFutureMigrations(false);
    classicConfiguration.setGroup(true);
    classicConfiguration.setLocations(new Location(FLYWAY_MIGRATION_FOLDER));
    classicConfiguration.setMixed(true);
    return new DhisFlyway(classicConfiguration, configurationProvider.isEnabled(FLYWAY_REPAIR_BEFORE_MIGRATION));
}
Also used : ClassicConfiguration(org.flywaydb.core.api.configuration.ClassicConfiguration) Location(org.flywaydb.core.api.Location) DependsOn(org.springframework.context.annotation.DependsOn) Profile(org.springframework.context.annotation.Profile) Bean(org.springframework.context.annotation.Bean)

Example 8 with Location

use of org.flywaydb.core.api.Location in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method useVendorDirectory.

@Test
void useVendorDirectory() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues("spring.flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog").run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactlyInAnyOrder(new Location("classpath:db/vendors/h2"), new Location("classpath:db/changelog"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 9 with Location

use of org.flywaydb.core.api.Location in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method useOneLocationWithVendorDirectory.

@Test
void useOneLocationWithVendorDirectory() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues("spring.flyway.locations=classpath:db/vendors/{vendor}").run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/vendors/h2"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 10 with Location

use of org.flywaydb.core.api.Location in project spring-boot by spring-projects.

the class Flyway5xAutoConfigurationTests method defaultFlyway.

@Test
void defaultFlyway() {
    this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/migration"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Aggregations

Location (org.flywaydb.core.api.Location)11 Flyway (org.flywaydb.core.Flyway)8 Test (org.junit.jupiter.api.Test)8 DataSourceAutoConfiguration (org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration)3 ArrayList (java.util.ArrayList)2 ClassicConfiguration (org.flywaydb.core.api.configuration.ClassicConfiguration)1 LoadableResource (org.flywaydb.core.api.resource.LoadableResource)1 ClassPathScanner (org.flywaydb.core.internal.scanner.classpath.ClassPathScanner)1 EmbeddedDataSourceConfiguration (org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration)1 Bean (org.springframework.context.annotation.Bean)1 DependsOn (org.springframework.context.annotation.DependsOn)1 Profile (org.springframework.context.annotation.Profile)1