Liquibase vs Flyway — Big Picture
| Aspect | Liquibase | Flyway |
|---|---|---|
| Philosophy | Declarative, metadata-driven | Simple, versioned SQL |
| Learning curve | Steeper | Very low |
| Migration format | XML / YAML / JSON / SQL | SQL (primary), Java |
| Rollbacks | First-class, explicit | Limited (mostly manual) |
| DB-agnostic | Strong | Weaker |
| Control & flexibility | High | Medium |
| Typical users | Large enterprises, regulated systems | Product teams, microservices |
✅ Pros
1. Declarative migrations
- You describe what you want, not how:
<addColumn tableName="user">
<column name="age" type="int"/>
</addColumn>
Liquibase generates DB-specific SQL.
2. Strong rollback support
- Rollbacks are explicit and structured.
- Critical for regulated environments (banks, insurance).
3. Database-agnostic
- Same changelog works for PostgreSQL, Oracle, MySQL.
- Useful in multi-DB or vendor-migration scenarios.
4. Preconditions
<preConditions>
<tableExists tableName="user"/>
</preConditions>
Prevents broken deployments.
5. Mature enterprise ecosystem
- Auditing, checksums, change tracking.
- Very good for compliance.
❌ Cons
1. Verbose & noisy
- XML/YAML is painful to review in PRs.
- Merge conflicts are common.
2. Higher cognitive load
- New devs struggle with concepts:
- changesets
- contexts
- labels
- preconditions
3. Overkill for small services
- Microservice with 5 tables? Liquibase is heavy.
🚀 Flyway
✅ Pros
1. Dead simple
-- V1__create_user_table.sql
CREATE TABLE user (
id BIGSERIAL PRIMARY KEY
);
Readable, reviewable, obvious.
2. SQL-first
- You control the exact SQL.
- No abstraction leaks.
3. Perfect for microservices
- Each service owns its schema.
- Very fast onboarding.
4. Predictable execution
- Strict version order: V1 → V2 → V3
- Easy mental model.
5. Lightweight
- Minimal config, minimal magic.
❌ Cons
1. Weak rollback story
- Rollbacks = write a new migration
UNDOmigrations exist but are limited and risky in prod
2. DB-specific SQL
- Vendor lock-in is real.
- PostgreSQL ≠ Oracle syntax.
3. Less metadata safety
- No built-in preconditions.
- You can shoot yourself in the foot with bad SQL.
🧠 Interview-Level Summary (say this)
Flyway is simpler, SQL-first, and ideal for microservices where each service owns its schema and forward-only migrations are acceptable.
Liquibase is more powerful and declarative, with strong rollback and database-agnostic support, making it better for enterprise or regulated systems—but at the cost of complexity.
💡 Senior Engineer Rule of Thumb
| Scenario | Choose |
|---|---|
| Microservices | Flyway |
| Startup / product team | Flyway |
| Banking / compliance | Liquibase |
| Multiple DB vendors | Liquibase |
| Small team, fast delivery | Flyway |
⚠️ Common Interview Pitfall
❌ “Liquibase is better because it has rollback”
✔️ Correct answer:
Rollbacks are rarely used in production; instead we rely on forward rollbacks. Liquibase’s rollback support is mainly valuable in regulated or controlled environments.