Database Migration Tools Compared: Flyway, Liquibase, Prisma Migrate, Atlas & goose
Database schema changes are among the riskiest deployments in any system. A bad migration can corrupt data, cause downtime, or leave the schema in an inconsistent state. Migration tools bring order to this chaos by versioning schema changes and applying them predictably across environments.
This guide compares five popular tools: Flyway, Liquibase, Prisma Migrate, Atlas, and goose.
What a Migration Tool Does#
At its core, a migration tool tracks which schema changes have been applied and which are pending. It maintains a metadata table (often called schema_history or migrations) and applies changes in order.
migrations/
V001__create_users.sql
V002__add_email_index.sql
V003__create_orders.sql ← pending
V004__add_status_column.sql ← pending
schema_history table:
version | description | applied_at
---------+--------------------+-------------------
001 | create_users | 2026-01-15 09:00
002 | add_email_index | 2026-02-01 14:30
Tool Overviews#
Flyway#
Flyway is a Java-based tool from Redgate that uses plain SQL migration files with a version prefix convention (V1__description.sql). It is mature, widely adopted, and integrates with Maven, Gradle, and CLI.
- Migration format: SQL files or Java callbacks
- Versioning: Sequential (
V1,V2) or timestamp-based - Rollback: Undo migrations available in paid Teams edition only
- Database support: 20+ databases including PostgreSQL, MySQL, Oracle, SQL Server
- Best for: Java/JVM teams that prefer plain SQL migrations
Liquibase#
Liquibase tracks changes using an XML, YAML, JSON, or SQL changelog. Its abstraction layer can generate database-specific SQL from a single changelog, making multi-database support stronger than Flyway's.
- Migration format: XML/YAML/JSON changelogs or raw SQL
- Versioning: Changeset IDs (author + id combination)
- Rollback: Built-in rollback generation for many change types; custom rollback SQL for others
- Database support: 50+ databases
- Best for: Teams managing schemas across multiple database vendors
Prisma Migrate#
Prisma Migrate is part of the Prisma ORM ecosystem for Node.js and TypeScript. You define your schema in a .prisma file, and the tool generates SQL migrations by diffing the schema against the database.
- Migration format: Generated SQL from declarative Prisma schema
- Versioning: Timestamp-based directories
- Rollback: No built-in rollback; you create a new migration to undo changes
- Database support: PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB, MongoDB
- Best for: TypeScript/Node.js teams already using Prisma ORM
Atlas#
Atlas takes a declarative, HCL-based approach inspired by Terraform. You define the desired state, and Atlas computes the migration plan. It also supports versioned migrations for teams that prefer explicit SQL files.
- Migration format: Declarative HCL or versioned SQL
- Versioning: Automatic plan generation or manual SQL files
- Rollback: Plan-based — Atlas can compute the reverse migration from the diff
- Database support: PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, ClickHouse
- Best for: Teams that want Terraform-like declarative schema management
goose#
goose is a lightweight Go-based tool that supports SQL and Go migration files. It is minimal by design — no DSL, no abstraction layer, just numbered SQL files.
- Migration format: SQL files or Go functions
- Versioning: Sequential or timestamp-based
- Rollback: Built-in down migrations via
-- +goose Downblocks - Database support: PostgreSQL, MySQL, SQLite, SQL Server, ClickHouse, Vertica
- Best for: Go teams that want a simple, dependency-free tool
Comparison Table#
| Feature | Flyway | Liquibase | Prisma Migrate | Atlas | goose |
|---|---|---|---|---|---|
| Language | Java | Java | Node.js/TS | Go | Go |
| Migration format | SQL | XML/YAML/SQL | Generated SQL | HCL/SQL | SQL/Go |
| Declarative mode | No | Diff changelog | Yes (schema file) | Yes (HCL) | No |
| Rollback | Paid only | Built-in | Manual | Computed | Built-in |
| Schema drift detection | Yes | Yes | Yes | Yes | No |
| Multi-database | 20+ | 50+ | 6 | 6 | 6 |
| CLI | Yes | Yes | Yes | Yes | Yes |
| Pricing | Free + paid | Free + paid | Free + paid | Free + paid | Free (OSS) |
| CI/CD plugins | Gradle/Maven/CLI | Gradle/Maven/CLI | npm scripts | GitHub Actions | CLI |
CI/CD Integration#
Every tool listed works in CI/CD pipelines, but integration depth varies.
Pipeline Pattern#
A typical migration pipeline looks like this:
┌────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐
│ PR Opens │──▶│ Lint / Dry │──▶│ Apply to │──▶│ Deploy │
│ │ │ Run Check │ │ Staging DB │ │ Application│
└────────────┘ └──────────────┘ └──────────────┘ └────────────┘
- Flyway and Liquibase: First-class Gradle and Maven plugins. Docker images available for CI runners. Both support
validateandinfocommands for dry runs. - Prisma Migrate: Integrates via
npx prisma migrate deployin npm scripts.prisma migrate diffshows pending changes without applying. - Atlas: Provides a GitHub Action (
ariga/atlas-action) that posts migration plans as PR comments.atlas migrate lintcatches destructive changes. - goose: Pure CLI — add
goose upto any shell step. No native CI plugin, but its simplicity makes scripting easy.
Schema Drift Detection#
Drift occurs when someone modifies the database manually, diverging from the migration history. Flyway, Liquibase, Prisma, and Atlas all detect drift. goose does not — it only checks its version table.
Rollback Strategies#
Rollback is where the tools diverge most:
-
Explicit down migrations (goose, Liquibase) — Each migration has a corresponding rollback script. This works well for additive changes (drop the column you added) but is dangerous for destructive ones (you cannot un-drop a column with data).
-
Computed rollback (Atlas) — The tool computes the reverse diff. This is convenient but requires review since auto-generated rollbacks can have data loss.
-
Forward-only (Prisma Migrate, Flyway free) — No rollback mechanism. You write a new migration to undo the previous change. This is the safest approach for production because rollback scripts are rarely tested.
Recommendation: Regardless of tool, treat rollbacks as a last resort. Prefer forward-only migrations with feature flags to control exposure. Test every migration in staging before production.
Handling Destructive Changes#
All tools let you write DROP TABLE or DROP COLUMN, but good tools warn you:
- Atlas:
atlas migrate lintflags destructive operations and blocks CI. - Liquibase:
--rollback-on-errorand preconditions can guard against dangerous changes. - Flyway: Teams edition includes check advisors that detect data-loss risks.
- Prisma: Warns when a migration will drop data during
prisma migrate dev. - goose: No built-in linting — rely on code review.
Migration Performance at Scale#
Large tables make migrations slow. Adding a column with a default to a billion-row table can lock it for hours. Strategies vary by tool:
- Use
CREATE INDEX CONCURRENTLY(PostgreSQL) — most tools support embedding this in SQL migrations. - Atlas and Liquibase can split migrations into online DDL steps.
- For very large tables, consider tools like gh-ost or pt-online-schema-change alongside your migration tool.
Decision Framework#
Choose based on your stack and priorities:
- JVM team, simple needs → Flyway
- JVM team, multi-database or complex workflows → Liquibase
- TypeScript/Node.js with Prisma ORM → Prisma Migrate
- Declarative, Terraform-like workflow → Atlas
- Go team, minimal tooling → goose
If you are starting fresh with no ecosystem constraints, Atlas offers the most modern developer experience with its declarative approach, CI integration, and computed rollbacks.
Key Takeaways#
- Migration tools version your schema changes and ensure they apply consistently across environments.
- Flyway and Liquibase are mature JVM tools with broad database support; Liquibase offers richer abstraction and built-in rollback.
- Prisma Migrate fits naturally into the TypeScript/Prisma ecosystem with a declarative schema-first approach.
- Atlas brings Terraform-like declarative workflows with strong CI/CD integration and drift detection.
- goose is minimal and effective for Go teams that want simplicity over features.
- Regardless of tool, prefer forward-only migrations, test in staging, and lint for destructive changes in CI.
Build and explore system design concepts hands-on at codelit.io.
392 articles on system design at codelit.io/blog.
Try it on Codelit
GitHub Integration
Paste any repo URL to generate an interactive architecture diagram from real code
Related articles
Try these templates
GitHub-like CI/CD Pipeline
Continuous integration and deployment system with parallel jobs, artifact caching, and environment management.
9 componentsCI/CD Pipeline Architecture
End-to-end continuous integration and deployment with testing, security scanning, staging, and production rollout.
10 componentsBuild this architecture
Generate an interactive architecture for Database Migration Tools Compared in seconds.
Try it in Codelit →
Comments