use of com.atherys.core.event.AtherysDatabaseMigrationEvent 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