Automated state-based deployments using the schema model
Published 11 October 2021
A Redgate Flyway Enterprise license is required to automate state-based database deployments.
This can be done with the following commands:
- flyway prepare
Use the schemaModel as your source and a target database to generate a deployment script that captures the differences and gets the dependency order correct. This uses Redgate's comparison technology for SQL Server, Oracle, PostgreSQL, and MySQL. - flyway deploy
Specify a target environment and deploy the script that was just generated by the flyway prepare command.
You can chain these commands together or call them separately to have a manual review step of the Deployment Script before it actually is deployed to the target environment. See our sample pipeline scripts.
Example:
# if target is specified in toml file flyway prepare deploy -prepare.source=schemaModel -prepare.target=production # if target is passed in via parameters flyway prepare deploy -environment=production -environments.production.url=<targetURL> -environments.production.user=<targetUser> -environments.production.password=<targetPassword>
If you need more control over your deployment scripts, we recommend using migration scripts. Flyway Enterprise can generate versioned (and optionally undo) migration scripts from your schema model. These scripts can then be edited, if needed, and saved in version control. This is the exact script that will run against your other environments and gives you full control over how changes are deployed. This also allows you to include data motion changes in your migration scripts as well. Flyway tracks which migration scripts have run on which databases and can tell when and how long they took. Flyway can then apply any pending migration scripts. For more details about migrations-based deployments, see Deploying database changes using Flyway.
Info
This was previously available in the flyway-dev preview, SQL Compare, and Compare for Oracle command lines. Now everything is completely integrated into the Flyway CLI, which works on Windows, MacOS, and Linux and is also available on Docker.
Additional capabilities
- Change Report for State-based deployments
- Code Analysis for State-based deployments
- Drift Report for State-based deployments using snapshots
- Pre and Post Deployment Scripts for State-based deployments
- Preview deployment script for State-based deployments (a. k. a. dry run script)
- Rollbacks for State-based deployments