Redgate Flyway

See migration scripts for multiple folders in Flyway Desktop

If you are using multiple folders for your migration scripts (e.g., this script only runs on my test environment, or I have custom data for each client), this article will show you how to see the migrations in different folder locations.

In this example, we have one versioned migrations script in our default migrations folder and we added a data/migrations folder to the root of our project.  The data/migrations folder also has one versioned migration script.  This contains sample data that should only run on our development database.  


Step-by-step guide

  1. Open your project in Flyway Desktop.
  2. Use the folder icon in the upper right to jump to your project files on disk.
  3. Open flyway.conf in your preferred IDE and search for flyway.locations.  Update this value to a specific folder or a or a comma separated list of folders that contain your migration scripts.  The value needs to start with filesystem: and then a path relative to your project folder (e.g., flyway.locations=filesystem:migrations,data/migrations).  Save the changes to the flyway.conf.

  4. In Flyway Desktop, go to your Migrations tab.  You'll now see all the Migrations across all the different locations you specified.
    1. If you have different folders for different environments, you'll need to edit the flyway.conf again and then change your target in the Migrations tab.



In the future, you will be able to do this through the GUI using the instructions below.

  1. Open your project in Flyway Desktop.
  2. Navigate to the Migrations tab and select a target database.  

    You may need to "Manage target databases" if you haven't set this up yet.

    1. The default Flyway Desktop folder is the migrations folder in the root of your project (-locations=filesystem:migrations).  In this case, only one sql file is in this folder, so only one migration appears in the list.    

  3. Click on Advanced settings and then Add parameters.


  4. Select locations in the dropdown.
    Enter a specific folder or a comma separated list of folders that contain your migration scripts for this target database.  The value needs to start with filesystem: and then a path relative to your project folder.  Note: all subfolders will also be included, so make sure you separate folders at a top level as needed.
    Click Add parameter and Save.  


  5.  Your location parameter appears in the right panel along with it's value, but there is still only one versioned migration in the list.  Click Refresh to pick up any changes.


  6. Now, migration scripts from all the locations you specified will appear in the table.



TODO: Check what happens if you have spaces in your path...


Note: If you want multiple locations to always show up for all your targets, then you can specify this value by jumping to your project folder on disk by using the folder icon in the upper rightand updating the -locations value in the flyway.toml settings. 

If you need help or have any questions about this, please contact the Database DevOps Team.





Didn't find what you were looking for?