Java Code Examples for org.flywaydb.core.Flyway#repair()
The following examples show how to use
org.flywaydb.core.Flyway#repair() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReaperApplication.java From cassandra-reaper with Apache License 2.0 | 6 votes |
private void initDatabase(ReaperApplicationConfiguration config) throws ReaperException { Flyway flyway = new Flyway(); DataSourceFactory dsfactory = config.getDataSourceFactory(); flyway.setDataSource( dsfactory.getUrl(), dsfactory.getUser(), dsfactory.getPassword()); if ("database".equals(config.getStorageType())) { LOG.warn("!!!!!!!!!! USAGE 'database' AS STORAGE TYPE IS NOW DEPRECATED !!!!!!!!!!!!!!"); LOG.warn("!!!!!!!!!! PLEASE USE EITHER 'postgres' OR 'h2' FROM NOW ON !!!!!!!!!!!!!!"); if (config.getDataSourceFactory().getUrl().contains("h2")) { flyway.setLocations("/db/h2"); } else { flyway.setLocations("/db/postgres"); } } else { flyway.setLocations("/db/".concat(config.getStorageType().toLowerCase())); } flyway.setBaselineOnMigrate(true); flyway.repair(); flyway.migrate(); }
Example 2
Source File: DatabaseMigrator.java From lemon with Apache License 2.0 | 6 votes |
public void doMigrate(String table, String location) { logger.info("migrate : {}, {}", table, location); Flyway flyway = new Flyway(); flyway.setPlaceholderPrefix("$${"); // flyway.setInitOnMigrate(true); flyway.setBaselineOnMigrate(true); // flyway.setInitVersion("0"); flyway.setBaselineVersionAsString("0"); flyway.setDataSource(dataSource); flyway.setTable(table); flyway.setLocations(new String[] { location }); try { flyway.repair(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } flyway.migrate(); }
Example 3
Source File: StartedListener.java From halo with GNU General Public License v3.0 | 5 votes |
/** * Migrate database. */ private void migrate() throws SQLException { log.info("Starting migrate database..."); Flyway flyway = Flyway .configure() .locations("classpath:/migration") .baselineVersion("1") .baselineOnMigrate(true) .dataSource(url, username, password) .load(); flyway.repair(); flyway.migrate(); // Gets database connection Connection connection = flyway.getConfiguration().getDataSource().getConnection(); // Gets database metadata DatabaseMetaData databaseMetaData = JdbcUtils.getDatabaseMetaData(connection); // Gets database product name HaloConst.DATABASE_PRODUCT_NAME = databaseMetaData.getDatabaseProductName() + " " + databaseMetaData.getDatabaseProductVersion(); // Close connection. connection.close(); log.info("Migrate database succeed."); }
Example 4
Source File: SkipperFlywayMigrationStrategy.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
@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(); }
Example 5
Source File: TinkerTimeLauncher.java From TinkerTime with GNU General Public License v3.0 | 5 votes |
@Override public void run() { // Perform Database Migration Flyway flyway = new Flyway(); flyway.setBaselineOnMigrate(true); flyway.setLocations("io/andrewohara/tinkertime/db/migration"); flyway.setDataSource(connectionString.getUrl(), null, null); try { flyway.migrate(); } catch (FlywayException e){ flyway.repair(); throw e; } }
Example 6
Source File: DbRepairCommand.java From dropwizard-flyway with Apache License 2.0 | 4 votes |
@Override public void run(final Namespace namespace, final Flyway flyway) throws Exception { flyway.repair(); }