Search in sources :

Example 6 with FluentConfiguration

use of org.flywaydb.core.api.configuration.FluentConfiguration in project ninja by ninjaframework.

the class MigrationEngineFlywayTest method prodModeCustomLocation.

@Test
public void prodModeCustomLocation() {
    FluentConfiguration mock = testMockedMigrate(NinjaMode.prod, ImmutableMap.of(NinjaConstant.NINJA_MIGRATION_LOCATIONS, "location"));
    InOrder inOrder = Mockito.inOrder(mock, mockedFlyway);
    inOrder.verify(mock).locations("location");
    inOrder.verify(mockedFlyway).migrate();
}
Also used : FluentConfiguration(org.flywaydb.core.api.configuration.FluentConfiguration) InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 7 with FluentConfiguration

use of org.flywaydb.core.api.configuration.FluentConfiguration in project ninja by ninjaframework.

the class MigrationEngineFlywayTest method testMockedMigrate.

private FluentConfiguration testMockedMigrate(NinjaMode ninjaMode, Map<String, String> customProperties) {
    FluentConfiguration mockedFluentConfiguration = mock(FluentConfiguration.class);
    mockedFlyway = mock(Flyway.class);
    when(mockedFluentConfiguration.load()).thenReturn(mockedFlyway);
    when(mockedFluentConfiguration.dataSource("testurl", "testuser", "testpassword")).thenReturn(mockedFluentConfiguration);
    MigrationEngineFlyway migrationEngineFlyway = getTestInstance(mockedFluentConfiguration, ninjaMode, customProperties);
    migrationEngineFlyway.migrate();
    return mockedFluentConfiguration;
}
Also used : FluentConfiguration(org.flywaydb.core.api.configuration.FluentConfiguration) MigrationEngineFlyway(ninja.migrations.flyway.MigrationEngineFlyway) Flyway(org.flywaydb.core.Flyway) MigrationEngineFlyway(ninja.migrations.flyway.MigrationEngineFlyway)

Example 8 with FluentConfiguration

use of org.flywaydb.core.api.configuration.FluentConfiguration in project ninja by ninjaframework.

the class MigrationEngineFlywayTest method prodModeDefault.

@Test
public void prodModeDefault() {
    FluentConfiguration mock = testMockedMigrate(NinjaMode.prod);
    InOrder inOrder = Mockito.inOrder(mock, mockedFlyway);
    inOrder.verify(mock).dataSource("testurl", "testuser", "testpassword");
    inOrder.verify(mock).load();
    inOrder.verify(mockedFlyway).migrate();
    verify(mockedFlyway, never()).clean();
}
Also used : FluentConfiguration(org.flywaydb.core.api.configuration.FluentConfiguration) InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 9 with FluentConfiguration

use of org.flywaydb.core.api.configuration.FluentConfiguration in project ninja by ninjaframework.

the class MigrationEngineFlywayTest method prodModeCustomSchema.

@Test
public void prodModeCustomSchema() {
    FluentConfiguration mock = testMockedMigrate(NinjaMode.prod, ImmutableMap.of(NinjaConstant.NINJA_MIGRATION_SCHEMAS, "schema"));
    InOrder inOrder = Mockito.inOrder(mock, mockedFlyway);
    inOrder.verify(mock).schemas("schema");
    inOrder.verify(mockedFlyway).migrate();
}
Also used : FluentConfiguration(org.flywaydb.core.api.configuration.FluentConfiguration) InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 10 with FluentConfiguration

use of org.flywaydb.core.api.configuration.FluentConfiguration in project AtherysCore by Atherys-Horizons.

the class DatabaseMigrator method migrate.

public void migrate() {
    logger.info("Beginning database migration...");
    String vendor = config.HIBERNATE.get(JPAConfig.URL_KEY).split(":")[1];
    AtherysDatabaseMigrationEvent event = new AtherysDatabaseMigrationEvent();
    Sponge.getEventManager().post(event);
    event.getPluginIds().forEach(pluginId -> {
        String location = String.format("classpath:db/migration/%s/%s", pluginId, vendor);
        logger.info("Migrating " + location);
        FluentConfiguration cfg = new FluentConfiguration().dataSource(config.HIBERNATE.get(JPAConfig.URL_KEY), config.HIBERNATE.get(JPAConfig.USERNAME_KEY), config.HIBERNATE.get(JPAConfig.PASSWORD_KEY)).schemas(pluginId).table("flyway_schema_history_" + pluginId).locations(location);
        new Flyway(cfg).migrate();
    });
    logger.info("Database migration complete.");
}
Also used : FluentConfiguration(org.flywaydb.core.api.configuration.FluentConfiguration) Flyway(org.flywaydb.core.Flyway) AtherysDatabaseMigrationEvent(com.atherys.core.event.AtherysDatabaseMigrationEvent)

Aggregations

FluentConfiguration (org.flywaydb.core.api.configuration.FluentConfiguration)10 Test (org.junit.Test)5 InOrder (org.mockito.InOrder)5 Flyway (org.flywaydb.core.Flyway)4 Configuration (org.flywaydb.core.api.configuration.Configuration)2 AtherysDatabaseMigrationEvent (com.atherys.core.event.AtherysDatabaseMigrationEvent)1 File (java.io.File)1 IOException (java.io.IOException)1 MigrationEngineFlyway (ninja.migrations.flyway.MigrationEngineFlyway)1 ClassicConfiguration (org.flywaydb.core.api.configuration.ClassicConfiguration)1 DbMigrate (org.flywaydb.core.internal.command.DbMigrate)1 Database (org.flywaydb.core.internal.database.base.Database)1 JdbcConnectionFactory (org.flywaydb.core.internal.jdbc.JdbcConnectionFactory)1 FlywayTrialExpiredException (org.flywaydb.core.internal.license.FlywayTrialExpiredException)1 Test (org.junit.jupiter.api.Test)1