Tutorial - Drift Report for deployments using snapshots
Published 02 April 2025
- After a successful deployment, use flyway snapshot to save the state of the database you just deployed to in a snapshot file. Save this snapshot to a location that is accessible to your release pipeline.
flyway snapshot -source=Prod -filename=deployedSnapshot.json
In the example above, "Prod" is the name of a database environment that is defined in the TOML file and provides the connection information for the database that you want to capture in a snapshot file. Before doing a deployment, use flyway check -drift to compare the snapshot saved above to the target database you're about to deploy to. If there are any changes, then your target database has drifted and it no longer matches the expected state captured above after your last deployment.
flyway check -drift -deployedSnapshot="deployedSnapshot.json" -environment="Prod" -failOnDrift=true
- Navigate to the Migration scripts page
- Connect to your target environment, by selecting the relevant connection from the Target database dropdown, or adding a new target configuration.
- Select Check from the command dropdown in the right hand pane
- Check the drift flag under the command dropdown
- Expand the Advanced settings and click Add parameters
- Select check.deployedSnapshot from the drop down. You can start typing to limit the results and find the parameter you need easier.
- Enter deploymentSnapshot.json for the parameter value.
- Click Add parameter.
- Repeat steps f-h, but this time set check.failOnDrift to true
- Click Back.
- Click Run check
- In this example, 1 object has changed since the snapshot was taken. Drilling down, you can see the exact changes - a new "DriftedColumn" was added to the Customers table.