2

Application.properties

TM_ESCALATION_QUALIFICATION=SHIFT_LEADER

Application.java

@Value( "${TM_ESCALATION_QUALIFICATION}" )
String escalationQualification;

@Bean
InitializingBean printConfigurations(DataSource datasource) {
    return () -> {
            Flyway flyway = new Flyway();
            flyway.setDataSource(datasource);
            flyway.getPlaceholders().put( "ESCALATION_QUALIFICATION", escalationQualification );    
            flyway.migrate();
    };
}

SQL file

insert into tm_qualification (ID, NAME, DELETABLE) values (sys_guid(), ${ESCALATION_QUALIFICATION}, 0); 

Above is working when I use file with default extension, but getting below error when I make file as .sql extension.

ERROR

org.flywaydb.core.api.FlywayException: No value provided for placeholder expressions: ${ESCALATION_QUALIFICATION}.  Check your configuration!
    at org.flywaydb.core.internal.util.PlaceholderReplacer.checkForUnmatchedPlaceholderExpression(PlaceholderReplacer.java:101)
    at org.flywaydb.core.internal.util.PlaceholderReplacer.replacePlaceholders(PlaceholderReplacer.java:78)
    at org.flywaydb.core.internal.dbsupport.SqlScript.<init>(SqlScript.java:79)....
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Pratap A.K
  • 4,337
  • 11
  • 42
  • 79

1 Answers1

3

From the web, suggestions are to use

flyway.placeholderReplacement=false

Which only worked after upgrading to > flyway 4.0.3 (spring boot latest uses ooold version)

Another thing that worked is use a bogus placeholder prefix and that did the trick...

flyway.placeholderPrefix=$$$-bogus-$$$

Tim Dugan
  • 94
  • 6