本文整理了Java中org.flywaydb.core.Flyway.repair()
方法的一些代码示例,展示了Flyway.repair()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway.repair()
方法的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
方法名:repair
暂无
代码示例来源:origin: jooby-project/jooby
@Override
public void run(final Flyway flyway) {
flyway.repair();
}
};
代码示例来源:origin: rakam-io/rakam
@Inject
public FlywayExecutor(@Named("report.metadata.store.jdbc") JDBCPoolDataSource config) {
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
flyway.setDataSource(config);
flyway.setLocations("db/migration/report");
flyway.setTable("schema_version_report");
try {
flyway.migrate();
} catch (FlywayException e) {
flyway.repair();
}
}
}
代码示例来源:origin: rakam-io/rakam
@Inject
public FlywayExecutor(@Named("ui.metadata.jdbc") JDBCConfig config) {
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
flyway.setLocations("db/migration/ui");
flyway.setTable("schema_version_ui");
flyway.setDataSource(config.getUrl(), config.getUsername(), config.getPassword());
try {
flyway.migrate();
} catch (FlywayException e) {
flyway.repair();
}
}
}
代码示例来源:origin: sixt/ja-micro
protected void migrateDatabase() {
try {
flyway.setTable(FLYWAY_SCHEMA_TABLE_NAME);
String url = "jdbc:" + serviceProps.getDatabaseServer();
flyway.setDataSource(url, serviceProps.getDatabaseUsername(),
serviceProps.getDatabasePassword());
//Use repair to fix the state if a migration failed and you corrected it.
if (serviceProps.getProperty("repairDatabase") != null) {
flyway.repair();
}
flyway.setValidateOnMigrate(false);
flyway.migrate();
} catch (Exception e) {
String message = "Error migrating database schema: " + e.getMessage() +
" Restart service with options '-repairDatabase true' after the problem" +
" has been corrected to resume migration.";
logger.error(message);
healthCheck.updateStatus(new HealthCheck("migration_failure",
HealthCheck.Status.FAIL, message));
try {
flywayFailedSemaphore.acquire(); //sleep forever
} catch (InterruptedException e1) {
}
}
}
代码示例来源:origin: org.flywaydb/flyway-gradle-plugin
@Override
protected Object run(Flyway flyway) {
flyway.repair();
return null;
}
}
代码示例来源:origin: org.jooby/jooby-flyway
@Override
public void run(final Flyway flyway) {
flyway.repair();
}
};
代码示例来源:origin: dropwizard/dropwizard-flyway
@Override
public void run(final Namespace namespace, final Flyway flyway) throws Exception {
flyway.repair();
}
}
代码示例来源:origin: com.hortonworks.registries/storage-tool
private void repair() {
flyway.repair();
}
代码示例来源:origin: hortonworks/registry
private void repair() {
flyway.repair();
}
代码示例来源:origin: hortonworks/registry
private void repair() {
flyway.repair();
}
代码示例来源:origin: com.hortonworks.registries/storage-tool
private void repair() {
flyway.repair();
}
代码示例来源:origin: stackoverflow.com
void migrate(Flyway flyway) {
String command = env.getProperty("flyway.commamd", "migrate");
switch (command) {
case "migrate":
flyway.migrate();
break;
case "repair":
flyway.repair();
break;
default:
throw new IllegalArgumentException("Invalid command: " + command);
}
}
代码示例来源:origin: org.seedstack.addons.flyway/flyway
@Override
public Integer call() throws Exception {
Flyway flyway = getFlyway();
System.out.println("Flyway: repairing datasource " + getDatasource());
flyway.repair();
return 0;
}
}
代码示例来源:origin: theotherp/nzbhydra2
protected static void repairDb(String databaseFilePath) throws ClassNotFoundException {
if (!databaseFilePath.contains("mv.db")) {
databaseFilePath = databaseFilePath + ".mv.db";
}
File file = new File(databaseFilePath);
if (!file.exists()) {
logger.error("File {} doesn't exist", file.getAbsolutePath());
}
databaseFilePath = file.getAbsolutePath().substring(0, file.getAbsolutePath().length() - 6);
Flyway flyway = new Flyway();
flyway.setLocations("classpath:migration");
Class.forName("org.h2.Driver");
JdbcDataSource dataSource = new JdbcDataSource();
dataSource.setURL("jdbc:h2:file:" + databaseFilePath);
dataSource.setUser("sa");
flyway.setDataSource(dataSource);
flyway.repair();
}
代码示例来源:origin: theotherp/nzbhydra2
@Override
public void migrate(Flyway flyway) {
try {
flyway.migrate();
} catch (FlywayException e) {
if (e.getMessage().contains("1.15")) {
logger.info("Found failed database migration. Attempting repair");
flyway.repair();
try {
flyway.getConfiguration().getDataSource().getConnection().createStatement().executeUpdate("delete from PUBLIC.\"schema_version\" where \"version\" = '1.15' or \"version\" = '1.16'");
} catch (SQLException e1) {
logger.error("Error while deleting old migration steps", e);
}
flyway.migrate();
} else {
logger.error("Unable to migrate", e);
throw e;
}
}
}
};
代码示例来源:origin: icode/ameba
/**
* <p>repair.</p>
*
* @param uuid a {@link java.lang.String} object.
* @return a {@link ameba.util.Result} object.
*/
@POST
@Path("{uuid}/repair")
public Result repair(@PathParam("uuid") String uuid) {
MigrationFeature.checkMigrationId(uuid);
if (failMigrations.isEmpty()) {
throw new NotFoundException();
}
for (String dbName : failMigrations.keySet()) {
MigrationFail fail = failMigrations.get(dbName);
fail.flyway.repair();
fail.migration.persist();
fail.migration.reset();
}
failMigrations.clear();
return Result.success();
}
代码示例来源:origin: stackoverflow.com
final ManagedDataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(),
"flyway-service");
final Flyway flyway = new Flyway();
flyway.setLocations(config.getFlywayFactory().getLocations().get(0));
flyway.setDataSource(dataSource);
flyway.repair(); //
flyway.migrate();
flyway.clean();
if (flyway.migrate() <= 0) {
throw new RuntimeException("migration failed!");
}
代码示例来源: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: spring-cloud/spring-cloud-skipper
@Override
public void migrate(Flyway flyway) {
MigrationInfo current = flyway.info().current();
if (current != null && current.getVersion().equals(INITIAL) && current.getType() == MigrationType.SQL) {
logger.info("Detected initial version based on SQL scripts, doing repair to switch to Java based migrations.");
flyway.repair();
}
flyway.migrate();
}
}
代码示例来源:origin: MarquezProject/marquez
private void migrateDbOrError(@NonNull MarquezConfig config) {
final Flyway flyway = new Flyway();
final DataSourceFactory database = config.getDataSourceFactory();
flyway.setDataSource(database.getUrl(), database.getUser(), database.getPassword());
// Attempt to perform a database migration. An exception is thrown on failed migration attempts
// requiring we handle the throwable and apply a repair on the database to fix any
// issues before terminating.
try {
flyway.migrate();
} catch (FlywayException e) {
log.error("Failed to apply migration to database.", e.getMessage());
log.info("Repairing failed database migration...", e.getMessage());
flyway.repair();
log.info("Successfully repaired database, stopping app...");
// The throwable is not propagating up the stack.
onFatalError(); // Signal app termination.
}
}
内容来源于网络,如有侵权,请联系作者删除!