Skip to content

Commit

Permalink
Support Flyway's defaultSchema configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 18, 2022
1 parent f3ee105 commit e3a1aaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.username=sa
quarkus.datasource.password=sa
quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test-quarkus-clean-at-start;DB_CLOSE_DELAY=-1;
quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test-quarkus-clean-at-start;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS TEST

# Flyway config properties
quarkus.flyway.clean-at-start=true
quarkus.flyway.migrate-at-start=false
quarkus.flyway.table=test_flyway_history
quarkus.flyway.default-schema=PUBLIC
quarkus.flyway.schemas=TEST,PUBLIC
quarkus.flyway.baseline-on-migrate=false
quarkus.flyway.baseline-version=0.0.1
quarkus.flyway.baseline-description=Initial description for test
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public Flyway createFlyway(DataSource dataSource) {
if (flywayRuntimeConfig.connectRetries.isPresent()) {
configure.connectRetries(flywayRuntimeConfig.connectRetries.getAsInt());
}
if (flywayRuntimeConfig.defaultSchema.isPresent()) {
configure.defaultSchema(flywayRuntimeConfig.defaultSchema.get());
}
if (flywayRuntimeConfig.schemas.isPresent()) {
configure.schemas(flywayRuntimeConfig.schemas.get().toArray(EMPTY_ARRAY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
@ConfigItem
public OptionalInt connectRetries = OptionalInt.empty();

/**
* Sets the default schema managed by Flyway. This schema name is case-sensitive. If not specified, but <i>schemas</i>
* is, Flyway uses the first schema in that list. If that is also not specified, Flyway uses the default schema for the
* database connection.
* <p>
* Consequences:
* </p>
* <ul>
* <li>This schema will be the one containing the schema history table.</li>
* <li>This schema will be the default for the database connection (provided the database supports this concept).</li>
* </ul>
*/
@ConfigItem
public Optional<String> defaultSchema = Optional.empty();

/**
* Comma-separated case-sensitive list of schemas managed by Flyway.
* The first schema in the list will be automatically set as the default one during the migration.
Expand Down

0 comments on commit e3a1aaa

Please sign in to comment.