本文整理了Java中org.flywaydb.core.Flyway
类的一些代码示例,展示了Flyway
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway
类的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
暂无
代码示例来源: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: 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: jooby-project/jooby
@Override
public void run(final Flyway flyway) {
flyway.repair();
}
};
代码示例来源:origin: apache/incubator-gobblin
private DatabaseJobHistoryStoreSchemaManager(Properties properties) {
flyway = new Flyway();
flyway.configure(properties);
flyway.setClassLoader(this.getClass().getClassLoader());
}
代码示例来源: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: 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: kawasima/enkan
@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();
}
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-server-backend-jdbi
@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;
}
代码示例来源:origin: mycontroller-org/mycontroller
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 {
代码示例来源: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: exomiser/Exomiser
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();
}
}
代码示例来源:origin: yasserg/crawler4j
Flyway flyway = new Flyway();
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: com.hortonworks.registries/storage-tool
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;
}
代码示例来源:origin: com.hortonworks.registries/storage-tool
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;
}
代码示例来源:origin: org.zalando/nakadi-producer-spring-boot-starter
@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();
}
代码示例来源:origin: StubbornJava/StubbornJava
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();
}
代码示例来源:origin: mbok/logsniffer
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());
代码示例来源:origin: at.chrl/chrl-orm
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;
}
代码示例来源:origin: org.amv.trafficsoft.datahub/xfcd-consumer-jdbc-spring-boot-starter
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();
}
}
内容来源于网络,如有侵权,请联系作者删除!