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


Java Flyway.setLocations方法代碼示例

本文整理匯總了Java中org.flywaydb.core.Flyway.setLocations方法的典型用法代碼示例。如果您正苦於以下問題:Java Flyway.setLocations方法的具體用法?Java Flyway.setLocations怎麽用?Java Flyway.setLocations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.flywaydb.core.Flyway的用法示例。


在下文中一共展示了Flyway.setLocations方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

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

示例4: prepareDataSourceContext

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
private static void prepareDataSourceContext(FlywayDataSourceContext dataSourceContext, Flyway flywayBean, FlywayTest annotation) throws Exception {
    if (isAppendable(flywayBean, annotation)) {
        dataSourceContext.reload(flywayBean);
    } else {
        String[] oldLocations = flywayBean.getLocations();
        try {
            if (annotation.overrideLocations()) {
                flywayBean.setLocations(annotation.locationsForMigrate());
            } else {
                flywayBean.setLocations(ObjectArrays.concat(oldLocations, annotation.locationsForMigrate(), String.class));
            }
            dataSourceContext.reload(flywayBean);
        } finally {
            flywayBean.setLocations(oldLocations);
        }
    }
}
 
開發者ID:zonkyio,項目名稱:embedded-database-spring-test,代碼行數:18,代碼來源:OptimizedFlywayTestExecutionListener.java

示例5: migrate

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
/**
 * Migrate the database to the latest available migration.
 */
public void migrate() {

  if (this.enabled) {
    final Flyway flyway = new Flyway();
    flyway.setDataSource(this.dataSource);
    if (this.testdata) {
      flyway.setLocations(masterDataPath, testDataPath);
    } else {
      flyway.setLocations(masterDataPath);
    }
    if (this.clean) {
      flyway.clean();
    }
    flyway.migrate();
  }
}
 
開發者ID:oasp,項目名稱:oasp-tutorial-sources,代碼行數:20,代碼來源:DatabaseMigrator.java

示例6: initDatasource

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
public void initDatasource(YadaConfiguration config) throws NamingException {
	MysqlDataSource dataSource = new MysqlDataSource();
	dataSource.setDatabaseName(config.getString("config/database/dbName"));
	dataSource.setUser(config.getString("config/database/user"));
	dataSource.setPassword(config.getString("config/database/password"));
	dataSource.setServerName(config.getString("config/database/server"));
	SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
	builder.bind("java:comp/env/jdbc/yadatestdb", dataSource);
	super.dataSource = dataSource;
	builder.activate();
	// Database
	Flyway flyway = new Flyway();
	flyway.setLocations("filesystem:schema"); // Where sql test scripts are stored
	flyway.setDataSource(dataSource);
	flyway.clean();
	flyway.migrate();
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:18,代碼來源:YadaTestConfig.java

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

示例8: initMigration

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
@BeforeClass
public static void initMigration() throws SQLException {
    flyway = new Flyway();
    flyway.setDataSource(DB_URL, "sa", "");
    flyway.setLocations("filesystem:src/main/resources/db/migration");
    flyway.migrate();

    connection = flyway.getDataSource().getConnection();
    //add some data to test db cleanup
    try (Statement stmt = connection.createStatement()) {
        stmt.addBatch("INSERT INTO flyway_test.author(id, first_name, last_name, date_of_birth, year_of_birth, address) VALUES (1, 'Erich', 'Gamma','1903-06-25','1900',null)");
        stmt.addBatch("INSERT INTO flyway_test.author(id, first_name, last_name, date_of_birth, year_of_birth, address) VALUES (2, 'Richard', 'Helm','1903-06-25','1900',null)");
        int[] result = stmt.executeBatch();
        assertEquals(result.length, 2);
    }
}
 
開發者ID:database-rider,項目名稱:database-rider,代碼行數:17,代碼來源:JooqDBUnitTest.java

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

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

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

示例12: apply

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
@Override public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override public void evaluate() throws Throwable {
      File yamlFile = new File(Resources.getResource("keywhiz-test.yaml").getFile());
      Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
      ObjectMapper objectMapper = KeywhizService.customizeObjectMapper(Jackson.newObjectMapper());
      KeywhizConfig config = new ConfigurationFactory<>(KeywhizConfig.class, validator, objectMapper, "dw")
          .build(yamlFile);

      DataSource dataSource = config.getDataSourceFactory()
          .build(new MetricRegistry(), "db-migrations");

      Flyway flyway = new Flyway();
      flyway.setDataSource(dataSource);
      flyway.setLocations(config.getMigrationsDir());
      flyway.clean();
      flyway.migrate();

      DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
      DbSeedCommand.doImport(dslContext);

      base.evaluate();
    }
  };
}
 
開發者ID:square,項目名稱:keywhiz,代碼行數:26,代碼來源:MigrationsRule.java

示例13: primaryFlyway

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
@Bean(initMethod = "migrate")
@FlywayDataSource
@Primary
public Flyway primaryFlyway(FlywayPrimaryProperties properties) {
	Flyway flyway = new Flyway();
	flyway.setDataSource(primaryDataSource);
	flyway.setLocations(properties.getLocation());
	return flyway;
}
 
開發者ID:drumonii,項目名稱:SpringBootTwoDataSources,代碼行數:10,代碼來源:FlywayConfig.java

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

示例15: startSchemaMigration

import org.flywaydb.core.Flyway; //導入方法依賴的package包/類
@PostConstruct
void startSchemaMigration() {
    final Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource());
    flyway.setLocations("classpath:/db/migration/mysql");

    flyway.migrate();
}
 
開發者ID:amvnetworks,項目名稱:amv-access-api-poc,代碼行數:9,代碼來源:EmbeddedMySqlConfig.java


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