Migrations-Based Approach – Flyway CLI
Published 23 December 2025
Want to skip ahead and use ready-made scripts? Clone the full repo here: Flyway Helper Files GitHub Repo.
Why choose Migrations-Based?
Migrations-based deployments manage database changes through versioned scripts, giving you full visibility and control over how changes are applied. This approach is:
- Ideal for teams who want explicit control over the evolution of their schema.
- Great for auditability—every change is tracked and versioned.
- Flexible for automation—works seamlessly with CI/CD pipelines.
Just like state-based, migrations-based workflows can auto-generate scripts, but at different points in the process. Think of it like driving a car:
- State-Based is like an automatic car—it handles a lot for you, but you still steer and decide where to go.
- Migrations-Based is like a manual car—you feel every gear change and have more control, but both approaches get you to the same destination.
Migrations-Based workflows typically involve two stages:
1. Developer Workflow Simulation
Commands like diff, model, and generate mimic what developers do in Flyway Desktop:
diff: Compares two sources (e.g., Development DB vs schema model) and shows the differences.
model: Analyzes the diff output and updates your Flyway Schema Model.
generate: Creates migration scripts based on differences for review and inclusion in your project.
2. DevOps Workflow Simulation
Commands like snapshot, check, migrate, and undo are used in CI/CD pipelines:
snapshot: Captures the state of a database for drift detection and auditability.
check: Validates that the migration scripts are safe and highlights any risks.
migrate: Applies pending migrations to the target database.
undo: Rolls back the most recent migration (Teams/Enterprise feature).
Not every customer needs both stages—if your goal is simply to apply migrations, you can start at migrate.
Using the Chinook Sample Database
For the fastest start, use the Chinook schema for SQL Server, PostgreSQL, Oracle, or MySQL. It’s included in our Flyway Helper Files repo here.
Run the setup script for your database engine, then proceed with the steps below.
(Prefer your own schema? That works too—just adjust the connection details accordingly.)
Next Steps
Below, you’ll find expandable sections for each command in the workflow. Each section includes:
Purpose – Why the command matters.
When to use – Where it fits in the workflow.
Helper script links – Quick access to ready-made scripts.
How to configure – Variables explained for easy setup.
What You’ve Achieved
Congratulations! You’ve now completed the Migrations-Based Flyway CLI workflow end-to-end:
- Captured differences between environments with Diff.
- Updated your schema model using Model.
- Generated versioned migration and undo scripts with Generate.
- Created snapshots for drift detection using Snapshot.
- Validated pending changes and code quality with Check.
- Applied migrations to your target environment using Migrate.
- Rolled back the last migration using Undo (Teams/Enterprise feature).
By following these steps, you’ve proven the migrations-based workflow works and mastered the basics of Flyway CLI for controlled, versioned deployments. This foundation gives you the flexibility to integrate Flyway into almost any workflow—including CI/CD pipelines—at your own pace.
Next Steps
- Explore more learning resources:
Redgate University offers self-paced courses to deepen your knowledge. - Need tailored guidance?
Redgate Professional Services can help with advanced scenarios or bespoke implementations. - Ready for full automation?
Check out the Flyway Autopilot guides for CI/CD pipeline setups and advanced workflows.