documentation/Reference/Commands/Deploy.md
{% include enterprise.html %}
The deploy command executes a deployment script against a target database and optionally takes and stores a snapshot
of the resulting database schema.
Can be used in conjunction with scripts generated by flyway prepare.
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.
flyway deploy -scriptFilename="D__deployment.sql" -environment=production -saveSnapshot=true
flyway prepare -source=schemaModel -target=production -scriptFilename=D__deployment.sql -saveSnapshot=true
flyway deploy -scriptFilename="D__deployment.sql" -environment=production
Note that it is also possible to chain these commands:
flyway prepare -source=schemaModel deploy -environment=production -saveSnapshot=true
flyway deploy -url="<url>" -user="<user>" -password="<password>" -saveSnapshot=true
| Parameter | Namespace | Description |
|---|---|---|
scriptFilename | deploy | The path to the script that will be deployed. |
saveSnapshot | deploy | Whether to generate a snapshot of the schema state after deployment. |
batch | (root) | Whether to batch SQL statements when executing them. |
configFiles | (root) | The location of the flyway configuration files. |
encoding | (root) | The encoding of the script to be deployed. |
environment | (root) | The name of the environment to deploy to. |
| {environment parameters} | (root) | Environment configuration for the target environment. |
executeInTransaction | (root) | Whether to run the script within a transaction. |
workingDirectory | (root) | The directory to consider the current working directory. All relative paths will be considered relative to this. |
Universal commandline parameters are listed here.
{
"scriptExecuted": "C:\\workingDirectory\\D__deployment.sql",
"deploymentResults": [],
"database": "production"
}
This command can produce the following error codes: