本文整理汇总了Java中org.flywaydb.core.Flyway.setBaselineVersionAsString方法的典型用法代码示例。如果您正苦于以下问题:Java Flyway.setBaselineVersionAsString方法的具体用法?Java Flyway.setBaselineVersionAsString怎么用?Java Flyway.setBaselineVersionAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.flywaydb.core.Flyway
的用法示例。
在下文中一共展示了Flyway.setBaselineVersionAsString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: migrateFlyway
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
public void migrateFlyway() {
Flyway flyway = new Flyway();
if (this.nakadiProducerFlywayDataSource != null) {
flyway.setDataSource(nakadiProducerFlywayDataSource);
} else if (this.flywayProperties.isCreateDataSource()) {
flyway.setDataSource(this.flywayProperties.getUrl(), this.flywayProperties.getUser(),
this.flywayProperties.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 (callback != null) {
flyway.setCallbacks(callback);
}
flyway.setBaselineOnMigrate(true);
flyway.setBaselineVersionAsString("2133546886.1.0");
flyway.migrate();
}
示例2: doMigrate
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
public void doMigrate(String table, String location) {
logger.info("migrate : {}, {}", table, location);
Flyway flyway = new Flyway();
flyway.setPlaceholderPrefix("$${");
// flyway.setInitOnMigrate(true);
flyway.setBaselineOnMigrate(true);
// flyway.setInitVersion("0");
flyway.setBaselineVersionAsString("0");
flyway.setDataSource(dataSource);
flyway.setTable(table);
flyway.setLocations(new String[] { location });
try {
flyway.repair();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
flyway.migrate();
}
示例3: start
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Override
public boolean start() {
_gcExecutor.scheduleWithFixedDelay(new ContainerClusterGarbageCollector(), 300, 300, TimeUnit.SECONDS);
_stateScanner.scheduleWithFixedDelay(new ContainerClusterStatusScanner(), 300, 30, TimeUnit.SECONDS);
// run the data base migration.
Properties dbProps = DbProperties.getDbProperties();
final String cloudUsername = dbProps.getProperty("db.cloud.username");
final String cloudPassword = dbProps.getProperty("db.cloud.password");
final String cloudHost = dbProps.getProperty("db.cloud.host");
final int cloudPort = Integer.parseInt(dbProps.getProperty("db.cloud.port"));
final String dbUrl = "jdbc:mysql://" + cloudHost + ":" + cloudPort + "/cloud";
try {
Flyway flyway = new Flyway();
flyway.setDataSource(dbUrl, cloudUsername, cloudPassword);
// name the meta table as sb_ccs_schema_version
flyway.setTable("sb_ccs_schema_version");
// make the existing cloud DB schema and data as baseline
flyway.setBaselineOnMigrate(true);
flyway.setBaselineVersionAsString("0");
// apply CCS schema
flyway.migrate();
} catch (FlywayException fwe) {
s_logger.error("Failed to run migration on Cloudstack Container Service database due to " + fwe);
return false;
}
return true;
}
示例4: init
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Override
public Map<String, String> init() throws SchemaInitializationException {
final Map<String, String> initResult = new HashMap<>();
try (final Connection conn = dataSource.getConnection()) {
final Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations(locations);
flyway.setClassLoader(Thread.currentThread().getContextClassLoader());
final DbSupport dbSupport = DbSupportFactory.createDbSupport(conn, true);
final MetaDataTable mt =
new MetaDataTableImpl(
dbSupport,
dbSupport.getOriginalSchema().getTable(flyway.getTable()),
flyway.getInstalledBy());
initResult.put(BARE_DB_INIT_PROPERTY_NAME, String.valueOf(!mt.hasAppliedMigrations()));
final String productName = conn.getMetaData().getDatabaseProductName().toLowerCase();
flyway.setResolvers(
new CustomSqlMigrationResolver(productName, dbSupport, placeholderReplacer));
flyway.setSkipDefaultResolvers(true);
flyway.setBaselineOnMigrate(baselineOnMigrate);
if (baselineOnMigrate) {
flyway.setBaselineVersionAsString(baselineVersion);
}
flyway.setSqlMigrationSeparator(versionSeparator);
flyway.setSqlMigrationSuffix(scriptsSuffix);
flyway.setSqlMigrationPrefix(scriptsPrefix);
flyway.migrate();
} catch (SQLException | RuntimeException x) {
throw new SchemaInitializationException(x.getLocalizedMessage(), x);
}
return initResult;
}
示例5: migrate
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
/**
* <p>migrate.</p>
*
* @param desc a {@link java.lang.String} object.
* @param uuid a {@link java.lang.String} object.
* @return a {@link ameba.util.Result} object.
*/
@POST
@Path("{uuid}")
public Result migrate(@FormParam("description") String desc,
@PathParam("uuid") String uuid) {
MigrationFeature.checkMigrationId(uuid);
String generatedDesc = (mode.isDev() ? "dev " : "") + "migrate";
if (StringUtils.isNotBlank(desc)) {
generatedDesc = desc;
}
Map<String, Migration> migrations = getMigrations();
for (String dbName : migrations.keySet()) {
Migration migration = migrations.get(dbName);
ScriptInfo info = migration.generate();
info.setDescription(generatedDesc);
Flyway flyway = locator.getService(Flyway.class, dbName);
flyway.setBaselineDescription(info.getDescription());
flyway.setBaselineVersionAsString(info.getRevision());
flyway.setValidateOnMigrate(false);
try {
flyway.migrate();
migration.persist();
migration.reset();
} catch (Throwable err) {
if (failMigrations == null) {
synchronized (this) {
if (failMigrations == null) {
failMigrations = Maps.newHashMap();
}
}
}
failMigrations.put(dbName, MigrationFail.create(flyway, err, migration));
}
}
if (failMigrations == null || failMigrations.isEmpty()) {
return Result.success();
} else {
return Result.failure();
}
}