Redgate Flyway

Tutorial - Roll back a state-based deployment

Pre-requisites

Steps to run

  1. Generate an undo script alongside a deployment script

    You can generate an undo script when running the prepare command as part of a deployment

    flyway prepare -source=schemaModel -target=production -types=deploy,undo -scriptFilename="D__deployment.sql" -undoFilename="DU__undo.sql"

    You should get confirmation of the operation success in the output

    Note that while the prepare command can be used for migrations-based deployments as well, generating undo scripts in this scenario is not currently supported.


  2. (Execute the deployment script)

    Run the deploy command

    flyway deploy -scriptFilename="D__deployment.sql" -environment=production

    You should get confirmation of the operation success in the output


  3. Execute the undo script
    flyway deploy -scriptFilename="DU__undo.sql" -environment=production

Related command reference


Didn't find what you were looking for?