100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Database

Flyway

By Redgate

IntermediateTool8.8K learners

Flyway is an open-source, SQL-first database migration tool that applies versioned schema changes in order and tracks execution history in a schema history table.

Definition

Flyway is an open-source, SQL-first database migration tool that applies versioned schema changes in order and tracks execution history in a schema history table.

Overview

Flyway takes a deliberately simple approach to schema migrations: each change is a plain SQL file named with a version prefix (for example `V1__create_users_table.sql`), and Flyway applies these files in strict numeric order against the target database, recording each one in a `flyway_schema_history` table. This convention-over-configuration design makes migrations easy to review in a pull request — a reviewer reading a `.sql` file sees exactly the DDL that will run, with no abstraction layer in between. Flyway is widely used in the Java ecosystem, with first-class integration into Spring Boot, Maven, and Gradle, though it also ships CLI and Docker distributions usable from any stack. On startup, a Spring Boot application configured with Flyway will automatically check for pending migrations and apply them before the application accepts traffic, which is a common pattern for keeping schema and code deployments in lockstep inside a CI/CD pipeline. Unlike Liquibase, Flyway's open-source edition does not support automatic rollback generation — rolling back a change generally means writing and applying a new forward migration that undoes it (undo migrations exist only in the paid Teams/Enterprise edition). This trade-off is intentional: Flyway's philosophy favors forward-only, immutable migration history as a simpler and more auditable model for production databases. Flyway supports PostgreSQL, MySQL, Oracle, SQL Server, and many other relational databases, and is frequently chosen by teams that want schema migrations to look and behave exactly like the raw SQL a DBA would write by hand.

Key Features

  • Versioned SQL migration files applied in strict numeric order
  • flyway_schema_history table tracks applied migrations and checksums
  • Native Spring Boot, Maven, and Gradle plugin integration
  • CLI and Docker image for use in any language or platform
  • Repeatable migrations for views, procedures, and seed data that can rerun on change
  • Checksum validation to detect and flag modified historical migration files
  • Baseline support for adopting Flyway on an existing, unmanaged database
  • Undo migrations and drift detection available in the commercial Teams edition

Use Cases

Applying versioned SQL migrations automatically on application startup
Keeping schema changes reviewable as plain SQL in pull requests
Synchronizing database schema across dev, test, and production environments
Seeding reference data through repeatable migration scripts
Adopting migration-based schema management on a legacy database via baselining
Integrating schema migrations into automated deployment pipelines

Frequently Asked Questions