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


Java Flyway.setBaselineVersion方法代码示例

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


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

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

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

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

示例4: dataSource

import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
/**
 * @return H2 pooled data source
 * @throws SQLException
 */
@Bean(destroyMethod = "dispose")
public DataSource dataSource() throws SQLException {
	final JdbcConnectionPool pool = JdbcConnectionPool.create(url, user, password);
	pool.setMaxConnections(maxPoolConnections);
	Connection con = null;
	con = pool.getConnection();

	final Flyway flyway = new Flyway();
	flyway.setLocations("classpath:sql/migration");
	flyway.setDataSource(pool);
	flyway.setSqlMigrationPrefix("VOS-");
	flyway.setIgnoreFailedFutureMigration(true);

	final JdbcTemplate tpl = new JdbcTemplate(pool);
	if (tpl.queryForObject("select count(*) from information_schema.tables where table_name = 'LOG_SOURCES'",
			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();
			dbPopulator.addScript(new ClassPathResource("/sql/quartz/tables_h2.sql"));
			dbPopulator.addScript(new ClassPathResource("/sql/model/schema_h2.sql"));
			dbPopulator.populate(con);
			newSchema = true;
			logger.info("Established H2 connection pool with new database");
		} finally {
			if (con != null) {
				con.close();
			}
		}
	} else {
		logger.info("Established H2 connection pool with existing database");
		if (tpl.queryForObject("select count(*) from information_schema.tables where table_name = 'schema_version'",
				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());

	return pool;
}
 
开发者ID:logsniffer,项目名称:logsniffer,代码行数:52,代码来源:DataSourceAppConfig.java


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