Redgate Flyway

Script change shows no differences

Problem:

A Flyway change report or migration difference view shows an object as having changed, but there are no visible changes.


Cause:

The scripts may differ only in nonprinting characters, often caused by differing newline styles. These discrepancies can be introduced by:

  1. Automatic procedural changes, most likely encountered in a pipeline.
  2. Manual script changes, such as reformatting via an IDE.

The scripts authored by our tools need to support multiple permutations of line endings, both denoting separations of code blocks as well as whatever line endings exist in the target databases' own data.

As demonstrated here, where context switches between db code and script formatting:

As a result of this, using an IDE or script editor to uniformly change the line endings will still result in differences because they will overwrite all line endings rather than altering them contextually.


Solutions:

  1. Git attributes file.
    This can ensure consistency, as Git can be configured to handle line endings in multiple ways and also avoid the possibility of auto-conversion introducing issues.
    Particularly useful if the code will transition across multiple platforms.

    *.sql -text diff
    *.rgm -text diff
  2. Performing code edits in the database rather than altering the scripts will negate the need to match the formatting.
    Alternatively you can just regenerate your migrations to overwrite the change.

  3. Displaying line ending symbols in your chosen editor may allow you to perform small modifications within the existing format.

Didn't find what you were looking for?