Migration placeholders
Published 06 January 2025
Flyway comes with support for placeholder replacement in:
Flyway does not currently support placeholder replacement in conjunction with Native Connectors.
For information on how to configure placeholders see Flyway Placeholders Namespace.
SQL Migration Placeholders
In addition to regular SQL syntax, Flyway also supports placeholder replacement with configurable prefixes and suffixes. By default it looks for Ant-style placeholders like ${myplaceholder}
. This can be very useful to abstract differences between environments.
Changing the value of placeholders will cause repeatable migrations to be re-applied on next migrate.
Placeholders are also provided as additional properties to the database connection, so placeholders reserved by your database (e.g. serverName
for SQL Server) will be used by the connection.
Placeholders are supported in versioned migrations, repeatable migrations, and SQL callbacks.
Flyway also provides default placeholders, whose values are automatically populated.
Examples
Default placeholders
GRANT SELECT ON SCHEMA ${flyway:defaultSchema} TO ${flyway:user};
User defined placeholder
INSERT INTO ${tableName} (name) VALUES ('Mr. T');
Script Migration Placeholders
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 __
. When accessing a placeholder that contains a colon (:
), you must replace the colon with an underscore (_
).
Examples
Powershell
echo $env:FP__flyway_filename__
Bash
echo $FP__flyway_filename__