I'm evaluating Flyway for use in my project. Our current SQL scripts contain placeholders for things like URLs which will have a different domain names depending on the environment (dev, qa, prod).
Specifically, we might have INSERT statements like
INSERT INTO FEED VALUES ('app.${env.token}.company.org/feed1', 'My Feed');
${env.token} needs to be replaced with 'dev', 'qa', or 'prod'.
We have about 50 different properties that could potentially need replacement in SQL scripts. The properties all reside in one or two properties files.
Is there a way to run the Flyway Ant migration task so that it pulls the replacement tokens and values from a properties file? Something along the lines of the Ant filter task?
Script Migration Placeholders Flyway Teams. Much like SQL placeholders, Flyway supports placeholder replacement in script migrations. Placeholders can be read through environment variables in your chosen scripting language and by default are prefixed by FP__ and suffixed by __ .
If not specified in schemas, Flyway will automatically attempt to create and clean this schema first. This schema will also be the default for the database connection (provided the database supports this concept).
Baseline is for introducing Flyway to existing databases by baselining them at a specific version. This will cause Migrate to ignore all migrations up to and including the baseline version. Newer migrations will then be applied as usual.
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.
Currently when supplying placeholders as properties, the property name should be prefixed with flyway.placeholders.
For example the ${env.token} placeholder can be specified directly as this Ant property: flyway.placeholders.env.token
There is currently no support for passing a property file directly, without using prefixes for the property names. Feel free to raise an issue in the Issue Tracker. :-)
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