private void checkConnection() { try (Connection connection = flyway.getDataSource().getConnection()) { // do nothing } catch (Exception e) { throw new SchemaMigrationException(e); } }
public RepeatableMigrationResolver(Flyway flyway, String prefix, Location location) throws SQLException { this.prefix = prefix; this.location = location; this.flyway = flyway; this.dbSupport = DbSupportFactory.createDbSupport(flyway.getDataSource().getConnection(), false); }
private void checkConnection() { try (Connection connection = flyway.getDataSource().getConnection()) { // do nothing } catch (Exception e) { throw new SchemaMigrationException(e); } }
private void create() throws SQLException { try (Connection connection = flyway.getDataSource().getConnection()) { if (!isDatabaseEmpty(connection)) throw new SchemaMigrationException("Please use an empty database or use \"migrate\" if you are already running a previous version."); } flyway.migrate(); }
private void create() throws SQLException { try (Connection connection = flyway.getDataSource().getConnection()) { if (!isDatabaseEmpty(connection)) throw new SchemaMigrationException("Please use an empty database or use \"migrate\" if you are already running a previous version."); } flyway.migrate(); }
@Override public void migrate(Flyway flyway) { final boolean newDatabase = isNewDatabase(flyway.getDataSource()); if (newDatabase) { LOGGER.info("First time initializing database..."); } else { LOGGER.info("Found existing database..."); } boolean existingLegacyDatabase = false; if (!StringUtils.isBlank(properties.getLegacyDatabaseDirectory())) { LOGGER.info("Found legacy database properties..."); final File legacyDatabaseFile = new File(properties.getLegacyDatabaseDirectory(), "nifi-registry.mv.db"); if (legacyDatabaseFile.exists()) { LOGGER.info("Found legacy database file..."); existingLegacyDatabase = true; } else { LOGGER.info("Did not find legacy database file..."); existingLegacyDatabase = false; } } // If newDatabase is true, then we need to run the Flyway migration first to create all the tables, then the data migration // If newDatabase is false, then we need to run the Flyway migration to run any schema updates, but no data migration flyway.migrate(); if (newDatabase && existingLegacyDatabase) { final LegacyDataSourceFactory legacyDataSourceFactory = new LegacyDataSourceFactory(properties); final DataSource legacyDataSource = legacyDataSourceFactory.getDataSource(); final DataSource primaryDataSource = flyway.getDataSource(); migrateData(legacyDataSource, primaryDataSource); } }
Flyway flyway = locator.getService(Flyway.class, dbName); boolean hasTable; try (Connection connection = flyway.getDataSource().getConnection()) { hasTable = connection.getMetaData().getTables(null, null, flyway.getTable(), null).next(); } catch (SQLException e) {
if (!flyway.getDataSource().getConnection().isClosed()) { flyway.getDataSource().getConnection().close(); _logger.debug("Closed flyway database connection.");
if (!flyway.getDataSource().getConnection().isClosed()) { flyway.getDataSource().getConnection().close(); _logger.debug("Closed flyway database connection.");