Tutorial - Run code review on deployment script
Published 16 September 2025
Pre-requisites
- Ensure that Flyway is installed and available on your path
- Ensure that any secrets necessary for database connection auth are available
Commands to run
- Use flyway prepare to generate your deployment script:
flyway prepare -source=schemaModel -target=Prod
This defaults to adding a D__deployment.sql file into a deployments folder in your current directory. - Run flyway check -code to run static code analysis checks against the generated deployment script:
flyway check -code -scope=script -scriptFilename="deployments/D__deployment.sql" -failOnError=true
The failOnError setting is optional, and causes the command to return an error if any code violations are detected.
Pre-requisites
- Enable Code review – Opt in Code review in the Preview Feature Dialog under the settings cog
- Save schema changes – Save changes from development database into schema model
- Configure code review rules – Configure the rules you want to apply to your scripts. If not configured, the default SQLFluff rules will be used. (Note: The default configuration is located in your Flyway Desktop installation folder, e.g., Flyway Desktop\flyway\conf)
How to view code violations while generating a deployment script
- Navigate to the Deploy changes page
- Select the objects you want to include in your deployment script ,then click the Deploy button on the top right corner.
- Once the deployment script is generated, if it contains any violations, a grey button will be shown indicating the total number of violations found from running code review. Clicking this toggles the code review side bar for the script. If no violations are found then a green check along with the message "Code review passed" will be shown instead.
Understanding the Code Review Side bar
- The sidebar shows the details of each code review violation, ordered by their appearance in the script and grouped by severity.
- For each violation you can,
- Click on the violation - This navigates the script editor to where the issue occurs.
- Ignore - Clicking this dismisses the violation by adding a comment at the end of the line. (Note: This is only available for certain rule types).
- Learn more - Clicking this opens documentation for the relevant rule in your browser.
- In addition, you can also navigate between issues using the Next and Previous buttons to step through the violations sequentially.
- To close the sidebar, click the grey issues button which was used in step 3 to toggle open sidebar.
Code review supports a maximum of 60,000 lines per script by default. If this limit is exceeded, code review will not run and no violations will be shown.


