Deploy Rules

This feature is currently available in a Private Preview.  If you are interested, please get in touch with our development team.

This feature is available in Flyway Teams or Flyway Enterprise.


If you ever needed to limit a script to run in a certain environment, then this feature is for you.  The following examples are common use cases for this:

  1. This is a test script.  We want it to run in our Test environment, but not in any other environments.
  2.  We deploy to many different clients.  Sometimes, we have to write bespoke scripts for a certain client.  These scripts should only run on Prod-ClientA and nowhere else.


The Flyway Teams/Enterprise command line has had this capability for a while.  Each migration script can have a script config file.  In that script configuration file, you can enter conditions for when the script should execute.


The Deploy Rules applied to each script will appear on the Migrations view.  In this example, the last two scripts have a Deploy Rule that specifies only execute if the environment is Test.  Since Prod2 is the selected target, these scripts have a status of Ignored.  They are not Pending.  They will not be applied to Prod2 if you ran the migrate command.


To add or edit your Deploy Rules after your Migration Script has been saved, use the drop down when viewing the script in the Migrations view.  Changing a Deploy Rule will not have any impact if the script has already been executed against an environment and there will be no checksum warning on Flyway validation.


You can also write your own custom rules that will be placed in the Migration Script's corresponding script config file.  You can learn more in this tutorial about injecting environments or on the script config file documentation.



Didn't find what you were looking for?