Redgate Flyway

Drift analysis

Flyway can check a target environment for drift, validating that no unexpected changes have been made since Flyway was last used to deploy to the database.  This is important because you want your development and test environments to reflect what is on Production.  If Production is changed, it could invalidate the testing in your earlier environments and cause a problem.

It is most common to check for drift right before doing a deployment to ensure that the target environment is still in the expected state.  Flyway's drift analysis can also be run ad hoc or on a schedule for a more proactive drift check to identify issues early and not just right before you're going to deploy to that environment.  If you are using Redgate Monitor, you can get drift alerts.  

When deploying using migrations, drift will likely only cause a problem if the drifted objects are being modified in the migrations being deployed or the drift is in objects that they depend on. Migration deployment will naturally ignore any drift since it's just running the versioned migration scripts.

When deploying using state, drift will be reverted as part of the deployment, unless ignored using comparison filters.

What is 'Schema Drift'?

Schema Drift occurs when a target database deviates from the codebase that was used to originally deploy it.

In this example, modifications were made to the live database after Version 1.2 was released. This effectively created a new version of the schema outside source control.

This could cause a problem when Version 1.3 is deployed, because the deployment package will expect the target database to be in the state of Version 1.2.

The most common example of drift is when a hotfix needs to be made directly to the Production environment.  It's important that change is incorporated into the earlier development and testing environments.  If not, it can be caught and corrected as part of a drift check in a CI/CD pipeline.

How to run drift analysis

The recommended approach to drift analysis is to store snapshots in the Flyway snapshot history table on deployment.

For more information, see Checking production environments for drift.


Didn't find what you were looking for?