diff --git a/src/main/docs/guide/configuration/jpa.adoc b/src/main/docs/guide/configuration/jpa.adoc index 04c1f57d..74729e5b 100644 --- a/src/main/docs/guide/configuration/jpa.adoc +++ b/src/main/docs/guide/configuration/jpa.adoc @@ -1,32 +1,49 @@ You can define Flyway configuration for each datasource. The following example demonstrates using it: -[source, yaml] .src/main/resources/application.yml +[configuration] ---- -include::{flywaytests}/groovy/io/micronaut/flyway/docs/FlywaySpec.groovy[tag=yamlconfig,indent=0] +datasources: + default: + url: 'jdbc:h2:mem:flywayDb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE' + username: 'sa' + password: '' + driverClassName: 'org.h2.Driver' +jpa: + default: + packages-to-scan: + - 'example.micronaut' + properties: + hibernate: + hbm2ddl: + auto: none + show_sql: true +flyway: + datasources: + default: + enabled: true ---- -<1> Disable schema DDL creation. -<2> Define flyway configuration under `flyway.datasources` key. -<3> Configure flyway configuration for `default` datasource. -<4> Enable the flyway migrations for the `default` datasource. +- Disable schema DDL creation with `jpa.default.properties.hibernate.hbm2ddl.auto` set to 'none' +- Define flyway configuration under `flyway.datasources` key. +- Configure flyway configuration for `default` datasource under `datasources.default` and `jpa.default` +- Enable the flyway migrations for the `default` datasource under `flyway.datasources.default` NOTE: You need to put the migrations in Flyway default directory `src/main/resources/db/migration`. If you want to modify the default directory or add more, you need to set the property `flyway.datasources.default.locations`. For example: -[source,yaml] +[configuration] ---- flyway: datasources: default: enabled: true locations: - - classpath:databasemigrations # <1> - - classpath:other # <1> + - classpath:databasemigrations + - classpath:other ---- -<1> This will configure Flyway to look for migrations in the directories `src/main/resources/databasemigrations` and -`src/main/resources/other`. +- The `locations` properties configure Flyway to look for migrations in the directories `src/main/resources/databasemigrations` and `src/main/resources/other`. Now, in the migration directory you can include your migrations: @@ -43,15 +60,14 @@ NOTE: Starting with Micronaut `1.1.3` it is not necessary to define the `jpa` co If you need more control to decide when the migrations are executed it is possible to configure the application like this: -[source,yaml] +[configuration] ---- flyway: - enabled: true # <1> + enabled: true datasources: default: - enabled: false # <2> + enabled: false ---- -<1> Flyway needs to be enabled -<2> Disable flyway migrations for your specific datasource +- Enable Flyway and disable flyway migrations for your specific datasource Now you can inject the `FlywayMigrator` bean and call manually the method `run` to execute the migrations when you want. diff --git a/src/main/docs/guide/endpoint.adoc b/src/main/docs/guide/endpoint.adoc index 34b0fb6a..0c663718 100644 --- a/src/main/docs/guide/endpoint.adoc +++ b/src/main/docs/guide/endpoint.adoc @@ -2,16 +2,15 @@ This configuration also provides a built-in endpoint to expose all the applied m To enable the endpoint add the following to the configuration: -[source,yaml] .resources/application.yml +[configuration] ---- endpoints: flyway: - enabled: true # <1> - sensitive: false # <2> + enabled: true + sensitive: false ---- -<1> `/flyway` endpoint is enabled (this is the default). -<2> `/flyway` endpoint is open for unauthenticated access. +- `/flyway` endpoint is enabled (this is the default) and open for unauthenticated access. [source,bash] ---- diff --git a/src/main/docs/guide/graalvm.adoc b/src/main/docs/guide/graalvm.adoc index be922697..78d3f121 100644 --- a/src/main/docs/guide/graalvm.adoc +++ b/src/main/docs/guide/graalvm.adoc @@ -8,16 +8,16 @@ to look for migrations you need to add an additional parameter to `native-image` For example, if you have the following configuration: -[source,yaml] +[configuration] ---- flyway: datasources: default: locations: - - classpath:databasemigrations # <1> - - classpath:other # <1> + - classpath:databasemigrations + - classpath:other ---- -<1> Flyway will look for migrations in `src/main/resources/databasemigrations` and `src/main/resources/other`. +- The `locations` properties configure Flyway to look for migrations in the directories `src/main/resources/databasemigrations` and `src/main/resources/other`. You need to use the parameter `flyway.locations` with a comma separated list of directories to look for: