Flyway

Snapshot Provisioner

Snapshot Provisioner - Preview

Flyway Enterprise

This provisioner allows for the provisioning and re-provisioning of databases using a snapshot file.

A snapshot captures the schema of a database and can be generated by using the snapshot command. Note that a snapshot is schema only and doesn't contain any static data. The snapshot provisioner can be used to speed up provisioning a shadow environment, as applying a snapshot that represents version 1000 is considerably quicker than running 1000 migrations scripts.

Prerequisites

  • A snapshot file generated using the snapshot command.
  • Set the environment variable REDGATE_FLYWAY_DIFF_VERB=true.

To configure this provisioner

  1. Set the value of the provisioner parameter to snapshot.
  2. Populate the following resolver properties:
    • filename - (Required) The file path of the snapshot file.
    • snapshotVersion - (Required) The migration version the snapshot represents. This version will be inserted as the baseline version into the flyway_schema_history table of the provisioned database.
    • cleanOnReprovision - (Optional) When set to true this option forces a clean of the provisioned database before the snapshot is applied. This option may be required when it's not possible to apply the snapshot to the database. For example, if applying the snapshot needs to re-add a non-null column to a table that has data in it.

Example

The snapshot provisioner can be used in the TOML configuration as follows:

[environments.development]
url = "jdbc:sqlserver://localhost:1433;databaseName=MyDatabase;trustServerCertificate=true"
user = "MyUser"
password = "${localSecret.MyPasswordKey}"
provisioner = "snapshot"

[environments.development.resolvers.snapshot]
filename = 'C:\Project\snapshot.snp'
snapshotVersion = "150"

This example will restore the snapshot file located at C:\Project\snapshot.snp to the development environment. The development environment will be at version 150.


Didn't find what you were looking for?