Get the most out of Flyway v7 - Sign up for our webinar on the Redgate Hub ▶ Watch now

Command-line: undo

Flyway Teams

Undoes the most recently applied versioned migration.

undo

Usage

> flyway [options] undo

Options

See configuration for a full list of supported configuration parameters.

Sample configuration

flyway.driver=org.hsqldb.jdbcDriver
flyway.url=jdbc:hsqldb:file:/db/flyway_sample
flyway.user=SA
flyway.password=mySecretPwd
flyway.connectRetries=10
flyway.initSql=SET ROLE 'myuser'
flyway.schemas=schema1,schema2,schema3
flyway.table=schema_history
flyway.locations=classpath:com.mycomp.migration,database/migrations,filesystem:/sql-migrations
flyway.sqlMigrationPrefix=Migration-
flyway.undoSqlMigrationPrefix=downgrade
flyway.repeatableSqlMigrationPrefix=RRR
flyway.sqlMigrationSeparator=__
flyway.sqlMigrationSuffixes=.sql,.pkg,.pkb
flyway.encoding=ISO-8859-1
flyway.placeholderReplacement=true
flyway.placeholders.aplaceholder=value
flyway.placeholders.otherplaceholder=value123
flyway.placeholderPrefix=#[
flyway.placeholderSuffix=]
flyway.resolvers=com.mycomp.project.CustomResolver,com.mycomp.project.AnotherResolver
flyway.skipDefaultCallResolvers=false
flyway.callbacks=com.mycomp.project.CustomCallback,com.mycomp.project.AnotherCallback
flyway.skipDefaultCallbacks=false
flyway.outputQueryResults=false
flyway.target=5.1
flyway.mixed=false
flyway.group=false
flyway.cleanOnValidationError=false
flyway.ignoreMissingMigrations=false
flyway.ignoreIgnoredMigrations=false
flyway.ignoreFutureMigrations=false
flyway.installedBy=my-user
flyway.errorOverrides=99999:17110:E,42001:42001:W
flyway.dryRunOutput=/my/sql/dryrun-outputfile.sql
flyway.oracle.sqlplus=true
flyway.oracle.sqlplusWarn=true
flyway.workingDirectory=C:/myProject
flyway.jdbcProperties.myProperty=value

Sample output

> flyway undo

Flyway 7.0.4 by Redgate

Database: jdbc:h2:file:C:\Programs\flyway-0-SNAPSHOT\flyway.db (H2 1.3)
Current version of schema "PUBLIC": 1
Undoing migration of schema "PUBLIC" to version 1 - First
Successfully undid 1 migration to schema "PUBLIC" (execution time 00:00.024s).

Sample JSON output

> flyway undo -outputType=json

{
  "initialSchemaVersion": "1",
  "targetSchemaVersion": null,
  "schemaName": "public",
  "undoneMigrations": [
    {
      "version": "1",
      "description": "undoFirst",
      "filepath": "C:\\flyway\\sql\\U1__undoFirst.sql"
    }
  ],
  "migrationsUndone": 1,
  "flywayVersion": "7.0.0",
  "database": "testdb",
  "warnings": []
}

Command-line: baseline