All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ec.gob.senescyt.sniese.commons.bundles.DBMigrationsBundle Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
package ec.gob.senescyt.sniese.commons.bundles;

import ec.gob.senescyt.sniese.commons.configurations.ConfiguracionSnieseBase;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.flywaydb.core.Flyway;

public class DBMigrationsBundle implements ConfiguredBundle {

    @Override
    public void run(T configuration, Environment environment) {
        Flyway flyway = new Flyway();
        DataSourceFactory dataSourceFactory = configuration.getConfiguracionPersistente().getDatabase();
        flyway.setDataSource(dataSourceFactory.getUrl(), dataSourceFactory.getUser(), dataSourceFactory.getPassword());
        flyway.setSchemas(configuration.getConfiguracionPersistente().getDefaultSchema());
        flyway.migrate();
    }

    @Override
    public void initialize(Bootstrap bootstrap) {
        // Do nothing.
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy