Can someone show the right format to use to use application.properties config in Flyway migrations.
I'd like to use the username for the datasource config in my application.properties file to grant permissions on a database table (db migration using Flyway, username will ultimately vary between environments), however I can't find an example of the syntax.
Example application.properties:
# Database
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/example_db
spring.datasource.username=example_db_application
spring.datasource.password=examplePassword1
Migration:
CREATE TABLE token
(
id TEXT,
value TEXT,
);
GRANT SELECT, INSERT, UPDATE, DELETE ON token TO ${spring.datasource.username};
I've tried various iterations (flyway.placeholders.spring.datasource.username, tried specifying no prefix: spring.flyway.placeholder-prefix=) but no luck.
Spring-Boot provides a common application-property for flyway migration placeholder-values under the path spring.flyway.placeholders.*=
# application.properties
# -> placeholder value `user`
spring.flyway.placeholders.user=joe
-- db/migration/V3__Migration_With_Placeholder.sql`:
CREATE TABLE ${user} (
...
)