org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlyWayConfig.java    From mojito with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: IdolFindMockConfigConfiguration.java    From find with MIT License 6 votes vote down vote up
@Bean
@Primary
public FlywayMigrationStrategy flywayMigrationStrategy() {
    return flyway -> {
        // terrible hack - using system properties to pass data to migration
        System.setProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_PROTOCOL, "HTTP");
        System.setProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_HOST, getProperty(COMMUNITY_HOST_PROPERTY, COMMUNITY_HOST));
        System.setProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_PORT, getProperty(COMMUNITY_PORT_PROPERTY, String.valueOf(COMMUNITY_PORT)));

        flyway.migrate();

        System.clearProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_PROTOCOL);
        System.clearProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_HOST);
        System.clearProperty(AbstractMigrateUsersToIncludeUsernames.COMMUNITY_PORT);
    };
}
 
Example #3
Source File: FlywayClassLoaderConfiguration.java    From sbp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public FlywayMigrationStrategy migrationStrategy() {
    return flyway -> {
        FluentConfiguration alterConf = Flyway.configure(plugin.getWrapper().getPluginClassLoader());
        alterConf.configuration(flyway.getConfiguration());
        new Flyway(alterConf).migrate();
    };
}
 
Example #4
Source File: RepositoryConfiguration.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Bean
public FlywayMigrationStrategy repairStrategy() {
    return flyway -> {
        flyway.repair();
        flyway.migrate();
    };
}
 
Example #5
Source File: CleanSchemaConfiguration.java    From sbp with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.flyway", name = "clean-before-migrate")
public FlywayMigrationStrategy migrationStrategy() {
    return new FlywaySchemaCleaner(plugin);
}
 
Example #6
Source File: EmptyMigrationStrategyConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public FlywayMigrationStrategy flywayMigrationStrategy() {
    return flyway -> {
        log.info("Skipping Flyway migration!");
    };
}