Redgate Flyway

Tutorial - Update SQL Server filter configuration


Opening the filter file configuration

  1. Launch Flyway Desktop
  2. Open a SQL Server project
  3. Navigate to the Schema Model page
  4. Click on "Configure Comparison"
  5. Select the "Filters" tab:


Using the filter configuration

Global filters

Global filters allow you to include or exclude objects by their parent schema and/or their object name.

  1. Next to "Global Filter" click on "Add Condition", this will present the following options:
  2. (Example) The following configuration would allow you to filter out all objects that are not within the development  schema:
  3. (Example) The following configuration would allow you to filter out any objects in any schema that start with "secret_":

Object filters

Object filters are similar to global filters in that you can choose to include or exclude objects by their parent schema and/or their object name, however they only apply to the object the condition is configured against. Note, that it is not possible for an Object Filter to re-include an object that is excluded within the Global Filter.

  1. Enter the object name into the search bar, or scroll to the appropriate object:
  2. Click on "Add Condition", this will present the following options:
  3. (Example) The following configuration will exclude all tables in any schema that start with "secret_":
  4. (Example) The following configuration will exclude all Assembly objects that start with "dev_". Note: Assemblies do not have a schema parent.
  5. (Example) If you wish to exclude any and all objects of a particular type, you can simply change the object to "Exclude" without needing to add a condition. This configuration will exclude Stored Procedures regardless of their name or the schema they're within:
  6. Conditions can be removed one at a time by clicking on the X button on the far right:

The Filter configuration tool within Flyway Desktop currently supports a subset of expressions.

For example, there are some AND  and LIKE  expressions that are not fully supported. When viewing a filter that contains unsupported expressions they will appear in a read-only text field against the object they relate to.


  1. Launch SQL Compare.

  2. Select your Development Database as the source and target and run the comparison. 

  3. After running the comparison, use the blue open folder in the Filter panel on the left to open the Filter file from your Flyway project.  


    1. Note: You can find the location of your Flyway project's filter file by using the blue folder on the top right of Flyway Desktop.
  4. Save any change to the Filter file.  


  5. In the Flyway Desktop Version control tab, commit and push this filter file to the remote repository so all team members have the same filter settings.

You can edit the filter file in the root folder of your Flyway project in Notepad or another editor.  Save your changes to the file and then use the Version control tab in Flyway Desktop to commit and push this filter file to the remote repository so all team members have the same filter settings.

The Filter file uses standard SQL Server LIKE and NOT LIKE syntax, which supports the following wildcards.

Wildcard
_matches any single character
%matches any sequence of characters

[^<range | character list>]

matches a range or character list


Examples

<!-- Here we are only including tables that begin with tbl_ -->
<!-- Note that since the underscore character is interpreted as a wildcard, it needs to be escaped in square brackets to denote the character -->
    <Table version="1">
        <Include>True</Include>
        <Expression>((@NAME LIKE 'tbl[_]%'))</Expression>
    </Table>

<!-- Here we are excluding tables that begin with test_ OR tables that begin with todo_ -->
    <Table version="1">
        <Include>False</Include>
        <Expression>((@NAME LIKE 'test[_]%')) OR ((@NAME LIKE 'todo[_]%'))</Expression>
    </Table>

<!-- Here we are excluding tables that belong to a schema named 'test' -->
    <Table version="1">
        <Include>False</Include>
        <Expression>((@SCHEMA = 'test'))</Expression>
    </Table>

Customizing the filter file path

A filter file will be picked up automatically if it is named Filter.scpf and in the root of the Flyway project directory. A different path can be specified if desired in the project settings TOML file under redgateCompare.sqlserver.

[redgateCompare.sqlserver]
filterFile = "Filter.scpf"

Didn't find what you were looking for?