Skip to main content
PreparationZone Logo
PrepZone

Liquibase vs Flyway

Choosing and running schema migration tools in Spring Boot 3.5.

Pass checkpoint below

Why this matters

  • Teams standardise on one migration tool — you must compare Flyway and Liquibase trade-offs.
  • Mixing tools on one schema corrupts migration history.
  • BookStore schema changes should follow expand-contract patterns in either tool.

Two migration tools

L1 · Fresher

Flyway is SQL-first; Liquibase supports XML/YAML changelogs with rollbacks — pick one per organization.

Liquibase changeSets

L2 · Intermediate

Each changeSet has an ID and author; Liquibase tracks execution in DATABASECHANGELOG.

Choosing for BookStore

L3 · Advanced

Flyway fits SQL-heavy teams; Liquibase helps when DBAs want abstract changelogs across Oracle and Postgres.

Never mix tools

L4 · Expert

Running Flyway and Liquibase on the same schema without coordination corrupts migration history.

Classpath scanFind @AutoConfiguration classes
@Conditional checksOnClass, OnBean, OnProperty
Register beansOnly if conditions pass
Boot checks classpath and existing beans before creating defaults.

Hook

BookStore adds a stock_quantity column before Black Friday. You need repeatable, reviewed SQL in git — not manual ALTER TABLE on production at 2 a.m. Flyway and Liquibase automate schema migration with Spring Boot 3.5.

Flyway defaults in Boot

Add org.flywaydb:flyway-core (often via spring-boot-starter-jdbc). Migrations live in src/main/resources/db/migration/ as V1__create_book.sql, V2__add_stock.sql.

Java
-- V2__add_stock_quantity.sql
ALTER TABLE book ADD COLUMN stock_quantity INTEGER NOT NULL DEFAULT 0;

Boot runs Flyway before JPA starts when both are present — entities must match the latest version.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 6 sections

  • Liquibase changelog
  • Java 21 + JPA alignment
  • BookStore in action
  • Runnable BookStore lab
  • Failure modes in production
  • Baseline and multi-schema

Test yourself

Answer these before moving on — recall is what makes it stick.