private DatabaseJobHistoryStoreSchemaManager(Properties properties) { flyway = new Flyway(); flyway.configure(properties); flyway.setClassLoader(this.getClass().getClassLoader()); }
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 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; }
@Override public void configure(final Env env, final Config conf, final Binder binder) { Config $base = flyway(conf.getConfig("flyway")); Config $flyway = Try.apply(() -> flyway(conf.getConfig(name)).withFallback($base)) .orElse($base); Flyway flyway = new Flyway(); Properties props = props($flyway); flyway.configure(props); if (!props.containsKey("flyway.url")) { Key<DataSource> dskey = Key.get(DataSource.class, Names.named(name)); DataSource dataSource = env.get(dskey) .orElseThrow(() -> new NoSuchElementException("DataSource missing: " + dskey)); flyway.setDataSource(dataSource); } // bind env.serviceKey() .generate(Flyway.class, name, key -> binder.bind(key).toInstance(flyway)); // commands: Iterable<Command> cmds = commands(conf); // eager initialization cmds.forEach(cmd -> cmd.run(flyway)); }
private void flywayMigrate(Configuration config, DataSource dataSource) { boolean enabled = getBool(config.getProperty("flyway.enabled", "true"), true); if(!enabled) { logger.debug("Flyway migrations are disabled"); return; } String migrationTable = config.getProperty("flyway.table", null); Flyway flyway = new Flyway(); if(null != migrationTable) { logger.debug("Using Flyway migration table '{}'", migrationTable); flyway.setTable(migrationTable); } flyway.setDataSource(dataSource); flyway.setPlaceholderReplacement(false); flyway.migrate(); }
private static MigrationVersion getDatabaseVersion(DataSource dataSource) throws FlywayException { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); MigrationInfoService info = flyway.info(); MigrationVersion currentVersion = MigrationVersion.EMPTY; if (info.current() != null) { currentVersion = info.current().getVersion(); } return currentVersion; }
@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(); }
private void flywayMigrate(DataSource dataSource) { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); flyway.setPlaceholderReplacement(false); flyway.migrate(); }
private synchronized static void flywayMigrate(DataSource dataSource) { if(EmbeddedDatabase.hasBeenMigrated()) { return; } synchronized (MySQLBaseDAOTest.class) { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); flyway.setPlaceholderReplacement(false); flyway.migrate(); } }
@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(); }
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(); }
@BeforeClass public static void init() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); database = builder.build(); flyway = new Flyway(); flyway.setBaselineVersion(MigrationVersion.fromVersion("1.5.2")); flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/"); flyway.setDataSource(database); flyway.migrate(); }
@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(); } } }
@Before public void setup() { props = new ServiceProperties(); healthcheck = new DatabaseMigrationContributor(props); connectionVerifier = mock(ConnectionVerifier.class); migrator = new SchemaMigrator(props, healthcheck, connectionVerifier, new Flyway()); }
@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(); } } }
@Bean(initMethod = "migrate") def flyway() = { val fly = new Flyway() fly.setDataSource(dataSource) fly }
public void runFlyWay() { Flyway flyway = new Flyway(); flyway.setDataSource( info.getProperty("url"), info.getProperty("user"), info.getProperty("password")); flyway.migrate(); }
class Migrator { public static void main(String[] args) throws Exception { ... Flyway flyway = new Flyway(); flyway.setDataSource(url, user, password); flyway.migrate(); } }
private void migrateDatabase() { String jdbcUrl = String.format(JDBC_URL_FORMAT, configuration.getHost(), configuration.getPort(), configuration.getSchema()); Flyway flyway = new Flyway(); flyway.setOutOfOrder(true); flyway.setDataSource(jdbcUrl, configuration.getUser(), configuration.getPassword()); flyway.migrate(); }