本文整理汇总了Java中org.flywaydb.core.Flyway.clean方法的典型用法代码示例。如果您正苦于以下问题:Java Flyway.clean方法的具体用法?Java Flyway.clean怎么用?Java Flyway.clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.flywaydb.core.Flyway
的用法示例。
在下文中一共展示了Flyway.clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanMigrateStrategy
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Bean
public FlywayMigrationStrategy cleanMigrateStrategy() {
FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() {
@Override
public void migrate(Flyway flyway) {
if (clean) {
logger.info("Clean DB with Flyway");
flyway.clean();
} else {
logger.info("Don't clean DB with Flyway");
}
flyway.migrate();
}
};
return strategy;
}
示例2: 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();
}
}
示例3: 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();
}
示例4: 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();
}
};
}
示例5: migrate
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Override
public void migrate(Flyway flyway) {
if (!databaseExists()) {
createDatabase();
}
flyway.clean();
flyway.migrate();
}
开发者ID:infobip,项目名称:infobip-spring-data-jpa-querydsl,代码行数:10,代码来源:SqlServerFlywayTestMigrationStrategy.java
示例6: cleanMigrationStrategy
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
/**
* Configures the Flyway migration strategy to clean the DB before migration first. This is used
* as the default unless the Spring Profile "production" is active.
*
* @return the clean-migrate strategy
*/
@Bean
@Profile("!production")
public FlywayMigrationStrategy cleanMigrationStrategy() {
FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() {
@Override
public void migrate(Flyway flyway) {
logger.info("Using clean-migrate flyway strategy -- production profile not active");
flyway.clean();
flyway.migrate();
}
};
return strategy;
}
示例7: cleanMigrationStrategy
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
/**
* Configures the Flyway migration strategy to clean the DB before migration first. This is used
* as the default unless the Spring Profile "production" is active.
* @return the clean-migrate strategy
*/
@Bean
@Profile("!production")
public FlywayMigrationStrategy cleanMigrationStrategy() {
FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() {
@Override
public void migrate(Flyway flyway) {
logger.info("Using clean-migrate flyway strategy -- production profile not active");
flyway.clean();
flyway.migrate();
}
};
return strategy;
}
示例8: prepareDataBase
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Bootstrapping
public static void prepareDataBase(final DataSource ds) {
// creates db schema and puts some data
final Flyway flyway = new Flyway();
flyway.setDataSource(ds);
flyway.clean();
flyway.migrate();
}
示例9: 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();
}
示例10: migrateDb
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
protected void migrateDb() {
Flyway flyway = new Flyway();
flyway.setDataSource(Postgres.datasource());
flyway.clean();
flyway.migrate();
// TODO Add some test data??
}
示例11: cleanMigrateStrategy
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Bean
public FlywayMigrationStrategy cleanMigrateStrategy() {
FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() {
@Override
public void migrate(Flyway flyway) {
flyway.clean();
flyway.migrate();
}
};
return strategy;
}
示例12: migrateH2Database
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
private static void migrateH2Database(DataSource h2DataSource, Map<String, String> propertyPlaceHolders) {
logger.info("Migrating exomiser H2 database...");
Flyway h2Flyway = new Flyway();
h2Flyway.setDataSource(h2DataSource);
h2Flyway.setSchemas("EXOMISER");
h2Flyway.setLocations("migration/common", "migration/h2");
h2Flyway.setPlaceholders(propertyPlaceHolders);
h2Flyway.clean();
h2Flyway.migrate();
}
示例13: checkNCreate
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
public void checkNCreate() {
Flyway flyway = new Flyway();
// flyway.setDataSource(globalProps.getProperty("jdbcUrl"), globalProps.getProperty("jdbcUser"), globalProps.getProperty("jdbcPwd"));
OpenConnectionCountDriverDataSource dataSource = OpenConnectionCountDriverDataSource.getInstance(Thread.currentThread().getContextClassLoader(), null, globalProps.getProperty("jdbcUrl"), globalProps.getProperty("jdbcUser"), globalProps.getProperty("jdbcPwd"));
flyway.setDataSource(dataSource);
flyway.setLocations("db/migration");
//Will wipe db each time. Avoid this in prod.
if (globalProps.getProperty("env").equals("dev")) {
flyway.clean();
}
//Remove the above line if deploying to prod.
flyway.migrate();
}
示例14: noConnectionLeak
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@Test
public void noConnectionLeak() {
OpenConnectionCountDriverDataSource dataSource = OpenConnectionCountDriverDataSource.getInstance(null);
assertEquals(0, dataSource.getOpenConnectionCount());
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql");
flyway.clean();
assertEquals(0, dataSource.getOpenConnectionCount());
assertEquals(4, flyway.migrate());
assertEquals(0, dataSource.getOpenConnectionCount());
}
示例15: init
import org.flywaydb.core.Flyway; //导入方法依赖的package包/类
@PostConstruct
public void init() {
if (!enabled) {
logger.info("skip dbmigrate");
return;
}
long startTime = System.currentTimeMillis();
if (clean) {
logger.info("clean database");
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.clean();
}
Map<String, ModuleSpecification> map = applicationContext
.getBeansOfType(ModuleSpecification.class);
for (ModuleSpecification moduleSpecification : map.values()) {
if (!moduleSpecification.isEnabled()) {
logger.info("skip migrate : {}, {}",
moduleSpecification.getSchemaTable(),
moduleSpecification.getSchemaLocation());
continue;
}
this.doMigrate(moduleSpecification.getSchemaTable(),
moduleSpecification.getSchemaLocation());
if (moduleSpecification.isInitData()) {
this.doMigrate(moduleSpecification.getDataTable(),
moduleSpecification.getDataLocation());
}
}
long endTime = System.currentTimeMillis();
logger.info("dbmigrate cost : {} ms", (endTime - startTime));
}