documentation/Reference/Commands/Migrate.md
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.
flyway migrate
mvn flyway:migrate
Note that default phase is pre-integration-test.
The new database version number is exposed in the flyway.current Maven property.
gradle flywayMigrate
| 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:
It is also possible to set environment settings as parameters.
All parameters are optional, although a target environment must be configured or passed in.
{
"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": "{{ site.flywayVersion }}",
"database": "testdb",
"warnings": [],
"operation": "migrate"
}
This command can produce the following error codes: