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.
Default placeholders ${flyway:user} = The user Flyway will use to connect to the database. ${flyway:database} = The name of the database from the connection url. ${flyway:timestamp} = The time that Flyway parsed the script, formatted as 'yyyy-MM-dd HH:mm:ss' ${flyway:filename} = The filename of the current script.
Spring boot flyway is application software of database migration which was used to migrate, validate, undo, clean, repair, and baseline commands of SQL. Flyway framework is basically used to update the database version using migration tools.
By default Flyway will look for migrations on the classpath under db/migration, which on a Maven project means src/main/resources/db/migration. You can however also use a location starting with the filesystem: prefix that can be anywhere on your disk.
The hotfix migration can be deployed with Flyway with skipExecutingMigrations=true . The schema history table will be updated with the new migration, but the script itself won't be executed again. skipExecutingMigrations can be used with with cherryPick to skip specific migrations.
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} (
...
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With