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();
}
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;
}
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();
}
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();
}
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.");
}
Aggregations