當前位置: 首頁>>代碼示例>>Java>>正文


Java Flyway.setBaselineVersionAsString方法代碼示例

本文整理匯總了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();
}
 
開發者ID:zalando-nakadi,項目名稱:nakadi-producer-spring-boot-starter,代碼行數:26,代碼來源:FlywayMigrator.java

示例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();
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:22,代碼來源:DatabaseMigrator.java

示例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;
}
 
開發者ID:shapeblue,項目名稱:ccs,代碼行數:34,代碼來源:ContainerClusterManagerImpl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:33,代碼來源:FlywaySchemaInitializer.java

示例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();
    }
}
 
開發者ID:icode,項目名稱:ameba,代碼行數:49,代碼來源:MigrationResource.java


注:本文中的org.flywaydb.core.Flyway.setBaselineVersionAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。