Redgate Flyway

Tutorial - Drift Report for deployments using embedded snapshot

FLYWAY ENTERPRISE

  1. Save a snapshot on deployment using one of the following options
    1. If using state-based deployments, save snapshots on deploy


      flyway deploy -environment=production -saveSnapshot=true

      Use this tutorial to deploy changes manually, but when reviewing the deployment script and before deploying (step 6 in the tutorial), make sure to check the Save snapshot checkbox:

    2. If using migrations-based deployment, save snapshots on migrate


      flyway migrate -baselineOnMigrate=true -environment=production -saveSnapshot=true

      Note that for migrations-based deployments it is also possible to use the prepare and deploy commands, as outlined for state-based deployments above.

      Use this tutorial to run migrate manually, but after selecting a target database (step 2 in the tutorial), set the migrate.saveSnapshot advanced parameter using the following steps

      1. Expand the Advanced settings and click Add parameters
      2. Select migrate.saveSnapshot from the drop down.  You can start typing to limit the results and find the parameter you need easier.
      3. Enter true for the parameter value.
      4. Click Add parameter.
      5. Click Back
    3. Or, take a snapshot ad-hoc, using the snapshot command


      flyway snapshot -source=production -filename="snapshotHistory:ad-hoc deployment"

      In the examples above, "production" is the ID of a database environment that is defined in the project and provides the connection information for the database that you want to capture in a snapshot.

      If this is the first time you're saving a snapshot in the target database, then the snapshot history table will be created.


  2. Use the saved snapshot in the target database to check for drift


    flyway check -drift -environment=production -failOnDrift=true


    1. Navigate to the Migration scripts page
    2. Connect to your target environment, by selecting the relevant connection from the Target database dropdown, or adding a new target configuration.
    3. Select Check from the command dropdown in the right hand pane
    4. Check the drift flag under the command dropdown
    5. Expand the Advanced settings and click Add parameters
    6. Select check.failOnDrift from the drop down.  You can start typing to limit the results and find the parameter you need easier.
    7. Enter true for the parameter value.
    8. Click Add parameter.
    9. Click Back.
    10. Click Run check
  3. Review the report
    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. 

Learn more



Didn't find what you were looking for?