当前位置: 首页>>代码示例>>Java>>正文


Java Flyway.setBaselineOnMigrate方法代码示例

本文整理汇总了Java中org.flywaydb.core.Flyway.setBaselineOnMigrate方法的典型用法代码示例。如果您正苦于以下问题:Java Flyway.setBaselineOnMigrate方法的具体用法?Java Flyway.setBaselineOnMigrate怎么用?Java Flyway.setBaselineOnMigrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.flywaydb.core.Flyway的用法示例。


在下文中一共展示了Flyway.setBaselineOnMigrate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initFlyway

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
/**
 * Initialise Flyway
 * 
 * @param ds
 */
private void initFlyway(DataSource ds) {
	try {
		logger.info("Database analysis: in progress...");
		Flyway flyway = new Flyway();
		flyway.setDataSource(ds);
		flyway.setCallbacks(new FlywayCallbackMigration());
		flyway.setBaselineOnMigrate(true);
		flyway.setValidateOnMigrate(true);
		flyway.repair();
		flyway.migrate();
		logger.info("Database analysis: finish...");
	} catch (Exception e) {
		logger.error("Database analysis: ERROR", e);
		throw e;
	}
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:22,代码来源:JpaConfigEcandidat.java

示例2: 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

示例3: updateDatabase

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
public void updateDatabase() throws IOException {
    try {
        Flyway flyway = new Flyway();
        flyway.setEncoding("UTF-8");
        flyway.setTable("flyway_schema");
        flyway.setLocations("db/migration");
        flyway.setSchemas(env.getProperty(PropertyNames.jdbcUser));
        flyway.setDataSource(
                env.getProperty(PropertyNames.jdbcURL),
                env.getProperty(PropertyNames.flywayUser),
                env.getProperty(PropertyNames.flywayPassword));

        flyway.setBaselineOnMigrate(true);
        flyway.migrate();
    } catch (Exception e) {
        log.error("FAILED TO MIGRATE DATABASE", e);
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:20,代码来源:JdbcConfiguration.java

示例4: 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

示例5: onStartup

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
    private void onStartup() {
        if (dataSource == null) {
            log.severe("No datasource found to execute the db migrations!");
            throw new EJBException("No datasource found to execute the db migrations!");
        }

        Flyway flyway = new Flyway();
        flyway.setDataSource(dataSource);
        flyway.setBaselineOnMigrate(true);
        for (MigrationInfo i : flyway.info().all()) {
            log.log(Level.INFO, "Migrate task: {0} : {1} from file: {2}", new Object[]{i.getVersion(), i.getDescription(), i.getScript()});
        }
        flyway.migrate();

        // aby ustawił kierunki relacji z pliku, odkomentować i ustawić ścieżkę do pliku disp_relations.cfg
//        try {
//            TempRelationsDirectionsUpdater.run("/home/rdyszlewski/Projekty/wordnetloom3/WordnetLoom/wordnetloom-client/src/main/resources/disp_relations.cfg", dataSource.getConnection());
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
    }
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:23,代码来源:DbMigrator.java

示例6: onStartup

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
private void onStartup() throws SQLException {
	if (dataSource == null) {
		LOG.error("no datasource found to execute the db migrations!");
		throw new EJBException(
				"no datasource found to execute the db migrations!");
	}

	String schema = "sql" + FS + "mysql";
	if (DB != null) {
		 schema = "sql" + FS + DB;
	}
	Flyway flyway = new Flyway();
	flyway.setDataSource(dataSource);
	flyway.setBaselineOnMigrate(true);
	flyway.setPlaceholderPrefix("%{");
	flyway.setLocations("sql" + FS + "configdata", schema);
	flyway.setBaselineVersion(MigrationVersion.fromVersion("201609221422"));
	for (MigrationInfo i : flyway.info().all()) {
		LOG.info("migrate task: " + i.getVersion() + " : "
				+ i.getDescription() + " from file: " + i.getScript());
	}
	flyway.repair();
	flyway.migrate();
}
 
开发者ID:witchpou,项目名称:lj-projectbuilder,代码行数:26,代码来源:DataStartupService.java

示例7: get

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
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.getClassLoader(), location, shellMigrationPrefix, shellMigrationSeperator, shellMigrationSuffix));
    flyway.setDataSource(conf.getUrl(), conf.getUser(), conf.getPassword(), null);

    return flyway;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:18,代码来源:ShellFlywayFactory.java

示例8: get

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
public static Flyway get(StorageProviderConfiguration conf, String scriptRootPath) {
    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;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:18,代码来源:SchemaFlywayFactory.java

示例9: initDatabase

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
private void initDatabase(ReaperApplicationConfiguration config) throws ReaperException {
  Flyway flyway = new Flyway();
  DataSourceFactory dsfactory = config.getDataSourceFactory();
  flyway.setDataSource(
      dsfactory.getUrl(),
      dsfactory.getUser(),
      dsfactory.getPassword());

  if ("database".equals(config.getStorageType())) {
    LOG.warn("!!!!!!!!!!    USAGE 'database' AS STORAGE TYPE IS NOW DEPRECATED   !!!!!!!!!!!!!!");
    LOG.warn("!!!!!!!!!!    PLEASE USE EITHER 'postgres' OR 'h2' FROM NOW ON     !!!!!!!!!!!!!!");
    if (config.getDataSourceFactory().getUrl().contains("h2")) {
      flyway.setLocations("/db/h2");
    } else {
      flyway.setLocations("/db/postgres");
    }
  } else {
    flyway.setLocations("/db/".concat(config.getStorageType().toLowerCase()));
  }
  flyway.setBaselineOnMigrate(true);
  flyway.repair();
  flyway.migrate();
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:24,代码来源:ReaperApplication.java

示例10: updateDatabase

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
public void updateDatabase() throws IOException {
    Flyway flyway = new Flyway();
    flyway.setEncoding("UTF-8");
    flyway.setTable("flyway_schema");
    flyway.setLocations("testmigration");
    flyway.setSchemas(env.getProperty(PropertyNames.jdbcUser));
    flyway.setDataSource(
            env.getProperty(PropertyNames.jdbcURL),
            env.getProperty(PropertyNames.flywayUser),
            env.getProperty(PropertyNames.flywayPassword));

    flyway.setBaselineOnMigrate(true);
    flyway.migrate();

}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:17,代码来源:IntegrationTestConfiguration.java

示例11: main

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
public static void main(String[] args) {
    Config config = ConfigFactory.load();

    Flyway flyway = new Flyway();
    flyway.setBaselineOnMigrate(true);
    flyway.setLocations(config.getString("migrations.location"));
    flyway.setDataSource(
            config.getString("jdbc.url"), 
            config.getString("jdbc.user"), 
            config.getString("jdbc.password"));
    flyway.migrate();
}
 
开发者ID:docker-production-aws,项目名称:microtrader,代码行数:13,代码来源:Migrate.java

示例12: 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

示例13: migrate

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
public void migrate() {
	// Create the Flyway instance
	Flyway flyway = new Flyway();

	// Point it to the database
	flyway.setDataSource(JDBCconnection.getConnectionString(),
			JDBCconnection.getUser(), JDBCconnection.getPassword());
	flyway.clean(); // limpando os schemas para sempre executar o flyway.
	flyway.setValidateOnMigrate(false);
	flyway.setBaselineOnMigrate(true);
	// Start the migration
	flyway.migrate();

}
 
开发者ID:willmenn,项目名称:DerbyPOC,代码行数:15,代码来源:Flyway3rdParty.java

示例14: 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

示例15: test

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Test
public void test() {
	// Create the Flyway instance
	Flyway flyway = new Flyway();

	// Point it to the database
	flyway.setDataSource("jdbc:hsqldb:mem:testdb;sql.syntax_ora=true",
			"sa", null);
	flyway.setBaselineOnMigrate(true);

	// Start the migration
	flyway.migrate();
}
 
开发者ID:interseroh,项目名称:report-cockpit-birt-web,代码行数:14,代码来源:MigrationDatabaseIT.java


注:本文中的org.flywaydb.core.Flyway.setBaselineOnMigrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。