Database comparisons
Published 23 December 2024
EDITION: TEAMS
Redgate comparison technology is currently only available for SQL Server, Oracle, PostgreSQL and MySQL and related database flavours
Redgate comparison technology makes it possible to compare the structure of two databases or capture the structure of a database in a schema model or a snapshot.
This technology underlies the schema model and migration generation workflows in Flyway Desktop.
It is possible to run custom comparisons using the Flyway `diff` command.
Comparison sources
Flyway can compare the following comparison sources:
Whenever migrations are compared a build environment needs to be brought up to date with the current migration state.
The empty comparison source is useful for getting the full list of objects in the comparison source on the other side of the comparison. For example, comparing your production database against empty will give the full list of objects needed to generate a baseline script.
Difference artifacts
Whenever flyway runs a comparison operation, it stores the calculated changes in a differences artifact which is read by subsequent commands such as generate
and model
.
If you ever have a support issue in relation to operations involving Redgate comparison technology, providing the associated diff artifact to Redgate support should allow Redgate to reproduce your issue, although these artifacts will contain database schema information.
By default, these artifacts are stored in a temporary location and overwritten during each comparison.
The changes captured in a difference artifact are always the changes that were present at the time the comparison was run. If the source or target environments changed in between calls to, for example, diff
and generate
then the generated script will not pick up these changes. As a result, it is intended that difference artifacts are short-lived.
Pulling in dependencies
For SQL Server and Oracle, when updating a schema model, updating a database, or generating a migration or other deployment script based upon a database comparison, Flyway will automatically look to pull in non-identical objects which your selected objects depend on.
This helps avoid generating scripts which won't deploy,
Comparison warnings
When generating deployment scripts, the Redgate comparison engines will return warnings with different severity levels for a wide range of potential issues. For example, if a script drops a table, that could mean potential data loss and a warning with a high warning level will be raised.
These are surfaced in the Flyway Desktop UI when generating migration scripts or other deployment scripts, and they can be used to abort pipelines which deploy from the schema model. Note that this shouldn't be necessary when deploying from generated migrations as the same validation will have already happened at development time when generating the migration.
Comparison configurations
For information on important configuration considerations when running database comparisons see the following child pages:
All configurations stored in the TOML config file will apply to all comparisons performed, whether that be generating migration scripts at development time or running drift analysis at deployment time. See Updating configurations for instructions on how to update the settings.
Generating scripts
The database comparisons are the basis for generation of deployment scripts and migrations.
While the majority of changes will be reproduced faithfully in the deployment script, there are a few types of changes that you need to be wary of, listed here.