Making SQLFluff code analysis more accessable
Published 03 July 2025
Flyway can run a set of static code analysis tools across your migrations using the check -code configuration which tests your SQL against one of several analysis engines (SQLFluff & Regex)
If you have an Enterprise license for Flyway then we've made it even easier to add SQLFluff to your code analysis tools.
Previously, Flyway relied on you having SQLFluff installed externally to Flyway and we know this caused problems for some people.
You would see this message:
Flyway SqlFluff code analysis requires Python 3, pip and SqlFluff version 1.2.1 or greater, preferably version 3.4.0
Run 'pip install sqlfluff==3.4.0' to install SqlFluff if you would like to access this function
What we've done is to wrap SQLFluff as an executable and include it in the Flyway CLI download (from Flyway v11.10.0)
(The Flyway Docker images have always come with SQLFluff included but Docker isn't a route that every organization can use)
Enabling the feature
This is currently in preview and you can enable it by setting an environment variable:
Powershell
$env:FLYWAY_ENV_NATIVE_SQLFLUFF = 'true'
Bash
export FLYWAY_ENV_NATIVE_SQLFLUFF='true'
What you'll see
Flyway will operate exactly as it does if you had SQLFluff installed separately from Flyway
Database: jdbc:sqlserver:// ... (Microsoft SQL Server 16.0)
SQLFluff code analysis summary:
Total analysis: 1 SQL file(s) scanned with dialect TSQL applied
Files with violations: 1 Violations: 17
We are currently working on improving Flyway's static analysis capabilities so look out for changes coming
Observations
This doesn't work on Ubuntu 20.04 (and older) as a dependency can't be satisfied. You'll see something like this:
[PYI-2516:ERROR] Failed to load Python shared library '/tmp/_MEIP3AK4i/libpython3.10.so.1.0': /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.35' not found (required by /tmp/_MEIP3AK4i/libpython3.10.so.1.0)