diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java index f0d3c1b7fcc9e..2676fc28ef513 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java @@ -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 diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java index 957b3fcbcdf31..3a6271647304c 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java @@ -113,4 +113,11 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() { */ @ConfigItem public Map placeholders = Collections.emptyMap(); + + /** + * Whether Flyway should attempt to create the schemas specified in the schemas property + */ + @ConfigItem(defaultValue = "true") + public boolean createSchemas; + } diff --git a/integration-tests/flyway/src/main/java/io/quarkus/it/flyway/FlywayFunctionalityResource.java b/integration-tests/flyway/src/main/java/io/quarkus/it/flyway/FlywayFunctionalityResource.java index c95001a96b428..8523f8f0f1fa7 100644 --- a/integration-tests/flyway/src/main/java/io/quarkus/it/flyway/FlywayFunctionalityResource.java +++ b/integration-tests/flyway/src/main/java/io/quarkus/it/flyway/FlywayFunctionalityResource.java @@ -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"); @@ -50,4 +50,9 @@ public Map returnPlaceholders() { return flyway.getConfiguration().getPlaceholders(); } + @GET + @Path("create-schemas") + public boolean returnCreateSchema() { + return flyway.getConfiguration().getCreateSchemas(); + } } diff --git a/integration-tests/flyway/src/test/java/io/quarkus/it/flyway/FlywayFunctionalityTest.java b/integration-tests/flyway/src/test/java/io/quarkus/it/flyway/FlywayFunctionalityTest.java index 306e67bf1bbe1..604dc6af5bbbd 100644 --- a/integration-tests/flyway/src/test/java/io/quarkus/it/flyway/FlywayFunctionalityTest.java +++ b/integration-tests/flyway/src/test/java/io/quarkus/it/flyway/FlywayFunctionalityTest.java @@ -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 @@ -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")); + } }