title: Flyway setting placeholders programmatically
body: <p>I have a very simple Spring Boot application which uses Flyway for database migrations. I want to set Flyway placeholders programmatically using Spring configuration class before migration starts. </p>
  
  <p>What I do is:  </p>
  
  <pre><code>@Configuration
  public class FlywayConfiguration {
  
    @Autowired
    private Flyway flyway;
  
    @Value("${threedsserver.db.tableSpaces.data:pg_default}")
    private String tablespaceData;
  
    @Value("${threedsserver.db.tableSpaces.index:pg_default}")
    private String tablespaceIndex;
  
    @Value("${threedsserver.db.tableSpaces.lob:pg_default}")
    private String tablespaceLob;
  
    @PostConstruct
    void setFlywayPlaceholders() {
      Map&lt;String, String&gt; placeholders = flyway.getPlaceholders();
      placeholders.put("tablespace_data", tablespaceData);
      placeholders.put("tablespace_index", tablespaceIndex);
      placeholders.put("tablespace_lob", tablespaceLob);
      flyway.setPlaceholders(placeholders);
    }
  }
  </code></pre>
  
  <p>Then in my migration script I use <code>${tablespace_data}</code> property. The migration fails with : </p>
  
  <pre><code>No value provided for placeholder expressions: ${tablespace_data}
  </code></pre>
  
  <p>I suppose the migration starts before the configuration file is processed. 
  How to fix this? I don't want to use application.properties for setting flyway placeholders, but all other properties like <code>spring.flyway.user</code>, <code>spring.flyway.password</code>, etc want to be set by the application.properties. </p>