Redgate Flyway

Migrate

Description

Migrates the schema to the latest version. Flyway will create the schema history table automatically if it doesn't exist.

Can optionally take a snapshot of the target database on deployment success and store it in the target database or elsewhere. This allows for drift detection on the target database, as well as providing one possible rollback mechanism.

See Migrations for more information.

Usage examples

Migrate via command line

flyway migrate

Migrate via Maven

mvn flyway:migrate

Note that default phase is pre-integration-test. The new database version number is exposed in the flyway.current Maven property.

Migrate via Gradle

gradle flywayMigrate

Parameters

Optional parameters specific to migrate

Parameter Namespace Description
saveSnapshot migrate Whether to generate a snapshot of the schema state after deployment.

Universal commandline parameters are listed here.

All relevant configuration settings are listed here. The settings from these sections can be set as parameters on the migrate command:

  • General settings
  • Migration location and naming settings
  • Migration reading settings
  • Migration execution settings
  • Flyway schema history settings
  • Flyway Pipelines integration settings
  • Baseline settings
  • Placeholders
  • Settings in database-specific namespaces
  • Settings in secrets management namespaces

It is also possible to set environment settings as parameters.

All parameters are optional, although a target environment must be configured or passed in.

JSON output format

{
  "initialSchemaVersion": null,
  "targetSchemaVersion": "1",
  "schemaName": "public",
  "migrations": [
    {
      "category": "Versioned",
      "version": "1",
      "description": "first",
      "type": "SQL",
      "filepath": "C:\\flyway\\sql\\V1__first.sql",
      "executionTime": 0
    },
    {
      "category": "Repeatable",
      "version": "",
      "description": "repeatable",
      "type": "SQL",
      "filepath": "C:\\flyway\\sql\\R__repeatable.sql",
      "executionTime": 0
    }
  ],
  "migrationsExecuted": 2,
  "flywayVersion": "11.17.0",
  "database": "testdb",
  "warnings": [],
  "operation": "migrate"
}

Error codes

This command can produce the following error codes:


Didn't find what you were looking for?