本文整理了Java中org.flywaydb.core.Flyway.setCallbacks()
方法的一些代码示例,展示了Flyway.setCallbacks()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway.setCallbacks()
方法的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
方法名:setCallbacks
暂无
代码示例来源:origin: cloudfoundry/uaa
public void run(MigrationTest... tests) {
final int[] assertionsRan = {0};
flyway.setCallbacks(new BaseFlywayCallback() {
@Override
public void afterEachMigrate(Connection connection, MigrationInfo info) {
super.afterEachMigrate(connection, info);
try {
connection.commit();
} catch (SQLException e) {
Assert.fail(e.getMessage());
}
for (MigrationTest test : tests) {
if (test.getTargetMigration().equals(info.getVersion().getVersion())) {
try {
test.runAssertions();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
assertionsRan[0]++;
}
}
}
});
flyway.migrate();
assertThat("Not every db migration ran", assertionsRan[0], is(tests.length));
}
}
代码示例来源:origin: org.arquillian.ape/arquillian-ape-sql-standalone-flyway
flyway.setCallbacks((FlywayCallback[]) this.options.get(CALLBACKS));
代码示例来源:origin: stackoverflow.com
@Component
public class CallbackFlywayMigrationStrategy implements FlywayMigrationStrategy {
@Override
public void migrate(Flyway flyway) {
flyway.setCallbacks(new LogMaintenanceFlywayCallback());
flyway.migrate();
}
}
代码示例来源:origin: stackoverflow.com
@Configuration
public class FlywayFactory {
@Bean
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {
flyway.setCallbacks(flywayCallback());
return new FlywayMigrationInitializer(flyway);
}
@Bean
public FlywayCallback flywayCallback() {
return new LogMaintenanceFlywayCallback();
}
}
代码示例来源:origin: ch.inftec.flyway/flyway-extension-core
public static void configure(Flyway flyway, Properties properties) throws SQLException {
flyway.setCallbacks(new BeforeAfterCallback(properties), new RepeatableCallback(flyway));
List<MigrationResolver> migrationResolvers = new ArrayList<>();
for (String locationDescriptor : flyway.getLocations()) {
migrationResolvers.add(new RepeatableMigrationResolver(flyway, "R", new Location(locationDescriptor)));
}
flyway.setResolvers(migrationResolvers.toArray(new MigrationResolver[0]));
}
}
代码示例来源:origin: at.chrl/chrl-orm
private boolean initFlyway(final String url, final String user, final String password){
out.println("[Hibernate Service] Run Flyway");
final Flyway flyway = new Flyway();
flyway.setDataSource(url, user, password);
flyway.setCallbacks(new HibernateCallback(out, err));
try {
flyway.baseline();
} catch (FlywayException e) {
flyway.repair();
}
try {
flyway.migrate();
} catch (Exception e) {
err.println("[Hibernate Service] Flyway Failed");
e.printStackTrace(err);
return false;
}
out.println("[Hibernate Service] Finished Flyway");
return true;
}
代码示例来源:origin: rchodava/datamill
public void migrate(Action1<Connection> migrationPreparation) {
Flyway flyway = getFlyway();
flyway.setCallbacks(new MigrationCallback(
typeAdapter != null ? typeAdapter.createConnectionPreparer() : null,
migrationPreparation));
flyway.migrate();
}
代码示例来源:origin: DSpace/DSpace
flywaydb.setCallbacks(flywayCallbacks.toArray(new FlywayCallback[flywayCallbacks.size()]));
} catch (SQLException e) {
log.error("Unable to setup Flyway against DSpace database", e);
代码示例来源:origin: org.zalando/nakadi-producer-spring-boot-starter
@PostConstruct
public void migrateFlyway() {
Flyway flyway = new Flyway();
if (this.nakadiProducerFlywayDataSource != null) {
flyway.setDataSource(nakadiProducerFlywayDataSource);
} else if (this.flywayProperties != null && this.flywayProperties.isCreateDataSource()) {
flyway.setDataSource(
Optional.ofNullable(this.flywayProperties.getUrl()).orElse(dataSourceProperties.getUrl()),
Optional.ofNullable(this.flywayProperties.getUser()).orElse(dataSourceProperties.getUsername()),
Optional.ofNullable(this.flywayProperties.getPassword()).orElse(dataSourceProperties.getPassword()),
this.flywayProperties.getInitSqls().toArray(new String[0]));
} else if (this.flywayDataSource != null) {
flyway.setDataSource(this.flywayDataSource);
} else {
flyway.setDataSource(dataSource);
}
flyway.setLocations("classpath:db_nakadiproducer/migrations");
flyway.setSchemas("nakadi_events");
if (callbacks != null) {
flyway.setCallbacks(callbacks.stream().map(FlywayCallbackAdapter::new).toArray(FlywayCallback[]::new));
}
flyway.setBaselineOnMigrate(true);
flyway.setBaselineVersionAsString("2133546886.1.0");
flyway.migrate();
}
代码示例来源:origin: org.leapframework/jmms-engine
protected Flyway createFlyway(OrmContext oc) {
Set<String> locations = new LinkedHashSet<>();
for(Resource dir : cfg.getDirs(cfg.getMigrationName())){
if(null != dir && dir.exists()) {
if (dir.hasClasspath()) {
locations.add(dir.getClasspath());
} else {
locations.add("filesystem:" + dir.getFilepath());
}
}
}
Resource cp = Resources.getResource("classpath:db/migration/");
if(cp.exists()) {
locations.add("db/migration");
}
if(locations.isEmpty()) {
return null;
}
Flyway flyway = new Flyway();
flyway.setResolvers();
flyway.setBaselineVersion(MigrationVersion.fromVersion("0"));
flyway.setCallbacks(new FlywayMigrateCallback());
flyway.setLocations(locations.toArray(new String[0]));
flyway.setDataSource(oc.getDataSource());
flyway.setValidateOnMigrate(false);
return flyway;
}
内容来源于网络,如有侵权,请联系作者删除!