本文整理了Java中org.flywaydb.core.Flyway.setDataSource()
方法的一些代码示例,展示了Flyway.setDataSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway.setDataSource()
方法的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
方法名:setDataSource
暂无
代码示例来源:origin: Netflix/conductor
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();
}
}
代码示例来源:origin: jdbi/jdbi
@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;
}
代码示例来源:origin: jooby-project/jooby
@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));
}
代码示例来源:origin: Netflix/conductor
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();
}
代码示例来源:origin: apache/incubator-gobblin
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;
}
代码示例来源:origin: jdbi/jdbi
@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();
}
代码示例来源:origin: Netflix/conductor
private void flywayMigrate(DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
flyway.migrate();
}
代码示例来源:origin: Netflix/conductor
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();
}
}
代码示例来源:origin: ninjaframework/ninja
@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();
}
代码示例来源:origin: yasserg/crawler4j
flyway.setDataSource(args[1], "crawler4j", "crawler4j");
flyway.migrate();
代码示例来源:origin: cloudfoundry/uaa
@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();
}
代码示例来源:origin: cloudfoundry/uaa
@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();
}
代码示例来源: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: qubole/quark
public void runFlyWay() {
Flyway flyway = new Flyway();
flyway.setDataSource(
info.getProperty("url"),
info.getProperty("user"),
info.getProperty("password"));
flyway.migrate();
}
代码示例来源:origin: stackoverflow.com
class Migrator {
public static void main(String[] args) throws Exception {
...
Flyway flyway = new Flyway();
flyway.setDataSource(url, user, password);
flyway.migrate();
}
}
代码示例来源:origin: logzio/apollo
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();
}
代码示例来源:origin: zonkyio/embedded-database-spring-test
@Bean
public Flyway flyway1(DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setSchemas("test");
flyway.setLocations("db/migration", "db/test_migration/dependent");
return flyway;
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Bean(initMethod = "migrate")
public Flyway flyway() {
Flyway flyway = new Flyway();
flyway.setDataSource(actualDataSource());
flyway.setBaselineOnMigrate(true);
flyway.setLocations(String.format("classpath:/flyway/db/%1$s/migration", databaseType()));
return flyway;
}
内容来源于网络,如有侵权,请联系作者删除!