Search code examples
flywaymicronaut

How to set flyway placeholders via micronaut application config?


I'm trying to run a migration script in a Micronaut app configured with Flyway integration. The app runs as expected and applies the migration scripts without any Flyway placeholders. However, whenever I add a Flyway placeholder to a migration script the application does not start anymore due to a FlywayException:

 org.flywaydb.core.api.FlywayException: No value provided for placeholder expressions: ${my_placeholder}.  Check your configuration!

I've tried to configure the placeholder in application.yml using the Micronaut Flyway placeholders configuration property (as described here https://micronaut-projects.github.io/micronaut-flyway/latest/guide/index.html#io.micronaut.configuration.dbmigration.flyway.FlywayConfigurationProperties) but the placeholder simply isn't picked up. The application.yml file looks like this:

flyway:
  datasources:
    default:
      locations: classpath:migrations
      placeholders:
        my_placeholder: "some value"

I've also tried creating a flyway.properties file with the placeholder defined according to what is described in this SO answer https://stackoverflow.com/a/9420671/2185719 but that did not work either

# flyway.properties
flyway.placeholders.my_placeholder=some value

Solution

  • While debugging Flyway startup (specifically in PlaceholderReplacingLine) I noticed that the placeholderReplacer object held a placeholder where the _ (underscores) had been replaced by - (dashes). Changing my_placeholder to my-placeholder in the migration script fixed the issue.