@Override public void before() throws Throwable { if (migration != null) { final Flyway flyway = new Flyway(); flyway.setDataSource(getDataSource()); flyway.setLocations(migration.paths.toArray(new String[0])); flyway.setSchemas(migration.schemas.toArray(new String[0])); flyway.migrate(); } jdbi = Jdbi.create(getDataSource()); if (installPlugins) { jdbi.installPlugins(); } plugins.forEach(jdbi::installPlugin); handle = jdbi.open(); }
@Override public void migrate() { // Get the connection credentials from application.conf String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL); String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME); String connectionPassword = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_PASSWORD); // We migrate automatically => if you do not want that (eg in production) // set ninja.migration.run=false in application.conf Flyway flyway = new Flyway(); flyway.setDataSource(connectionUrl, connectionUsername, connectionPassword); // In testmode we are cleaning the database so that subsequent testcases // get a fresh database. if (ninjaProperties.getBooleanWithDefault(NinjaConstant.NINJA_MIGRATION_DROP_SCHEMA, ninjaProperties.isTest() ? true : false )) { flyway.clean(); } flyway.migrate(); }
@Override public void run(final Flyway flyway) { flyway.repair(); } };
private DatabaseJobHistoryStoreSchemaManager(Properties properties) { flyway = new Flyway(); flyway.configure(properties); flyway.setClassLoader(this.getClass().getClassLoader()); }
@Override public void after() { if (migration != null && migration.cleanAfter) { final Flyway flyway = new Flyway(); flyway.setDataSource(getDataSource()); flyway.setLocations(migration.paths.toArray(new String[0])); flyway.setSchemas(migration.schemas.toArray(new String[0])); flyway.clean(); } handle.close(); jdbi = null; dataSource = null; }
private void flywayMigrate(DataSource dataSource) { boolean enabled = configuration.isFlywayEnabled(); if (!enabled) { logger.debug("Flyway migrations are disabled"); return; } Flyway flyway = new Flyway(); configuration.getFlywayTable().ifPresent(tableName -> { logger.debug("Using Flyway migration table '{}'", tableName); flyway.setTable(tableName); }); flyway.setDataSource(dataSource); flyway.setPlaceholderReplacement(false); flyway.migrate(); } }
@Override public void start(FlywayMigration component) { DataSourceComponent dataSourceComponent = getDependency(DataSourceComponent.class); DataSource dataSource = dataSourceComponent.getDataSource(); component.flyway = new Flyway(Thread.currentThread().getContextClassLoader()); component.flyway.setTable(table); component.flyway.setBaselineOnMigrate(true); component.flyway.setBaselineVersionAsString("0"); component.flyway.setDataSource(dataSource); if (component.locations != null) { component.flyway.setLocations(component.locations); } if (isMigrationAvailable()) { component.flyway.migrate(); } }
@Bean(initMethod = "migrate") @Autowired @Qualifier(value = "pds") public Flyway flyway(DataSource pds) { Flyway flyway = new Flyway(); flyway.setDataSource(pds); // could be another datasource with different user/pwd... flyway.setLocations("classpath:/de/digitalcollections/cudami/server/backend/impl/database/migration"); flyway.setBaselineOnMigrate(true); return flyway; }
Flyway flyway = new Flyway(); flyway.setTable("schema_version"); flyway.setDataSource(AppProperties.getInstance().getDbUrl(), AppProperties.getInstance().getDbUsername(), AppProperties.getInstance().getDbPassword()); flyway.setLocations(DB_MIGRATION_SCRIPT_LOCATION); flyway.setBaselineOnMigrate(true); migrationsCount = flyway.migrate(); } catch (FlywayException fEx) { _logger.error("Migration exception, ", fEx); if (fEx.getMessage().contains("contains a failed migration")) { flyway.repair(); migrationsCount = flyway.migrate(); if (!flyway.getDataSource().getConnection().isClosed()) { flyway.getDataSource().getConnection().close(); _logger.debug("Closed flyway database connection."); .builder() .version(mcAbout.getGitVersion()) .dbVersion(flyway.info().current().getVersion() + " - " + flyway.info().current().getDescription()) .build().updateInternal(); } else {
@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(); } } }
private static void migrateH2Database(DataSource h2DataSource, Map<String, String> propertyPlaceHolders) { logger.info("Migrating exomiser H2 database..."); Flyway h2Flyway = new Flyway(); h2Flyway.setDataSource(h2DataSource); h2Flyway.setSchemas("EXOMISER"); h2Flyway.setLocations("migration/common", "migration/h2"); h2Flyway.setPlaceholders(propertyPlaceHolders); h2Flyway.clean(); h2Flyway.migrate(); } }
Flyway flyway = new Flyway(); flyway.setDataSource(args[1], "crawler4j", "crawler4j"); flyway.migrate();
@BeforeClass public static void setUpDatabase() throws Exception { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); database = builder.build(); Flyway flyway = new Flyway(); flyway.setBaselineVersion(MigrationVersion.fromVersion("1.5.2")); flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/"); flyway.setDataSource(database); flyway.migrate(); }
public static Flyway get(StorageProviderConfiguration conf, String scriptRootPath) { Flyway flyway = new Flyway(); String location = "filesystem:" + scriptRootPath; flyway.setEncoding(encoding); flyway.setTable(metaDataTableName); flyway.setValidateOnMigrate(validateOnMigrate); flyway.setOutOfOrder(outOfOrder); flyway.setBaselineOnMigrate(baselineOnMigrate); flyway.setBaselineVersion(MigrationVersion.fromVersion(baselineVersion)); flyway.setCleanOnValidationError(cleanOnValidationError); flyway.setLocations(location); flyway.setResolvers(new ShellMigrationResolver(flyway.getConfiguration(), location, shellMigrationPrefix, shellMigrationSeperator, shellMigrationSuffix)); flyway.setDataSource(conf.getUrl(), conf.getUser(), conf.getPassword(), null); return flyway; }
public static Flyway get(StorageProviderConfiguration conf, String scriptRootPath, boolean validateOnMigrate) { Flyway flyway = new Flyway(); String location = "filesystem:" + scriptRootPath + File.separator + conf.getDbType(); flyway.setEncoding(encoding); flyway.setTable(metaDataTableName); flyway.setSqlMigrationPrefix(sqlMigrationPrefix); flyway.setValidateOnMigrate(validateOnMigrate); flyway.setOutOfOrder(outOfOrder); flyway.setBaselineOnMigrate(baselineOnMigrate); flyway.setBaselineVersion(MigrationVersion.fromVersion(baselineVersion)); flyway.setCleanOnValidationError(cleanOnValidationError); flyway.setLocations(location); flyway.setDataSource(conf.getUrl(), conf.getUser(), conf.getPassword(), null); return flyway; }
@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(); }
public static void migrate() { Flyway flyway = new Flyway(); flyway.setDataSource(CMSConnectionPools.processing()); flyway.setBaselineOnMigrate(true); flyway.setLocations("db/cms/migration"); flyway.setSqlMigrationPrefix("V_"); flyway.setTable("_flyway"); flyway.migrate(); }
con = pool.getConnection(); final Flyway flyway = new Flyway(); flyway.setLocations("classpath:sql/migration"); flyway.setDataSource(pool); flyway.setSqlMigrationPrefix("VOS-"); flyway.setIgnoreFailedFutureMigration(true); int.class) == 0) { logger.info("H2 database not found, creating new schema and populate with default data"); flyway.setBaselineVersion(MigrationVersion.fromVersion(DB_SETUP_VERSION)); flyway.setBaselineOnMigrate(true); try { final ResourceDatabasePopulator dbPopulator = new ResourceDatabasePopulator(); int.class) == 0) { logger.info("Flyway's DB migration not setup in this version, set baseline version to 0.5.0"); flyway.setBaselineVersion(MigrationVersion.fromVersion("0.5.0")); flyway.setBaselineOnMigrate(true); logger.debug("Migrating database, base version is: {}", flyway.getBaselineVersion()); flyway.migrate(); logger.debug("Database migrated from base version: {}", flyway.getBaselineVersion());
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; }
private void startSchemaMigration() { final Flyway flyway = new Flyway(); flyway.setDataSource(jdbcConsumerHikariDataSource()); flyway.setLocations(properties.getFlywayScriptsLocation()); log.info("Starting Trafficsoft Delivery schema migration v{}", flyway.getBaselineVersion().getVersion()); flyway.migrate(); } }