Skip to content

Commit

Permalink
Merge pull request #10662 from mejlholm/flyway-create-schema
Browse files Browse the repository at this point in the history
Add configuration for Flyway new feature, to make it selectable whether to create schemas or not.
  • Loading branch information
gsmet authored Jul 12, 2020
2 parents d90be61 + 180e018 commit c2218f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public Flyway createFlyway(DataSource dataSource) {
configure.baselineDescription(flywayRuntimeConfig.baselineDescription.get());
}
configure.placeholders(flywayRuntimeConfig.placeholders);
configure.createSchemas(flywayRuntimeConfig.createSchemas);

/*
* Ensure that no classpath scanning takes place by setting the ClassProvider and the ResourceProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
*/
@ConfigItem
public Map<String, String> placeholders = Collections.emptyMap();

/**
* Whether Flyway should attempt to create the schemas specified in the schemas property
*/
@ConfigItem(defaultValue = "true")
public boolean createSchemas;

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public String doMigrateAuto() {
}

@GET
@Path("multiple-flyway-migratation")
public String doMigratationOfSecondDataSource() {
@Path("multiple-flyway-migration")
public String doMigrationOfSecondDataSource() {
flyway2.migrate();
MigrationVersion version = Objects.requireNonNull(flyway2.info().current().getVersion(),
"Version is null! Migration was not applied for second datasource");
Expand All @@ -50,4 +50,9 @@ public Map<String, String> returnPlaceholders() {
return flyway.getConfiguration().getPlaceholders();
}

@GET
@Path("create-schemas")
public boolean returnCreateSchema() {
return flyway.getConfiguration().getCreateSchemas();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testFlywayQuarkusFunctionality() {
@Test
@DisplayName("Migrates a schema correctly using second instance of Flyway")
public void testMultipleFlywayQuarkusFunctionality() {
when().get("/flyway/multiple-flyway-migratation").then().body(is("1.0.0"));
when().get("/flyway/multiple-flyway-migration").then().body(is("1.0.0"));
}

@Test
Expand All @@ -30,4 +30,9 @@ public void testPlaceholders() {
when().get("/flyway/placeholders").then().body("foo", is("bar"));
}

@Test
@DisplayName("Returns whether the createSchemas flag is used or not")
public void testCreateSchemasDefaultIsTrue() {
when().get("/flyway/create-schemas").then().body(is("true"));
}
}

0 comments on commit c2218f3

Please sign in to comment.