ALL LESSONS Module 9

Database Migrations Flyway

Apr 5, 2026 1 min read

Schema Version Control

Track and manage database schema changes.

Flyway Setup

spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration

V1__create_tables.sql:
CREATE TABLE products (id BIGINT PRIMARY KEY, name VARCHAR(100));

V2__add_indexes.sql:
CREATE INDEX idx_product_name ON products(name);

Migration Features

  • Automatic execution on startup
  • Version tracking table
  • Rollback support
  • Repeatable migrations

Need help with this lesson? Visit the Discussion Forum