Deploying database changes using Flyway
Published 11 October 2021
State-based deployments
For SQL Server, Oracle, PostgreSQL, and MySQL:
- Flyway Teams - manual state-based deployments from the Schema model
- Flyway Enterprise - manual state-based deployments or automated state-based deployments with additional security and reports
Migrations-based deployments
All editions of Flyway allow you to deploy migration scripts. Use the Migrations tab in Flyway Desktop or automate using the migrate cli or Flyway Docker container. See our example CI/CD Pipelines for how to automate your changes using migration scripts.
Learn more about the different state-based and migrations-based deployment approaches.
Sample CI/CD process for all deployments
- Check out scripts from version control.
- CI - Build, analyze, and test database changes.
- Build - The build validates your scripts and makes sure they can run successfully.
- Analyze - Code analysis checks - Make sure you're not using deprecated syntax, changing security settings, or dropping data. You can also enforce naming conventions are being followed.
- Test - Testing can be unit tests, integration tests, regression tests, performance tests, etc. Having a few smoke tests that run on every build and give quick feedback to ensure the most critical parts of your system are not broken is a good idea.
- Build - The build validates your scripts and makes sure they can run successfully.
- Deploy to Test environment
- Execute your scripts on a test environment
- Execute your scripts on a test environment
- Deploy to additional environments (if needed).
- You may have additional test environments or Quality Assurance (QA)/User Acceptance Testing (UAT) environments that need to be deployed to. Using an automated process helps ensure the consistency of your environments.
- You may have additional test environments or Quality Assurance (QA)/User Acceptance Testing (UAT) environments that need to be deployed to. Using an automated process helps ensure the consistency of your environments.
- Deploy to a Staging/Pre-Production environment (optional)
- A Staging/Pre-Production environment is as similar to your Production environment as possible. It may even have a copy of Production data, so that the deployment can be tested on a realistic environment as possible before going to Production.
- Staging/Pre-Production environments can also be used to check how long a deployment will take to run. This information can be used to schedule deployments for off hours or down time as needed.
- Deploy to Production
- Manual intervention before going to Production
- Review the Change Report to quickly see how many objects will be changed. Drill into a side-by-side difference of each object to understand the changes easily and determine if there's any impact.
- Review the SQL script - This is the exact script that will be executed on the Production Environment.
- Check for Drift to make sure no objects have changed in Production since your last deployment. This ensures that the Staging/Pre-Production deployment you did really reflects the deployment to Production and that no Production hot fixes will cause issues with the current deployment. *
- Deploy your changes.
- Log changes (in SQL Monitor) and/or in Flyway Pipelines.
- Manual intervention before going to Production
* These capabilities are only available for SQL Server, Oracle, PostgreSQL and MySQL.