Skip to content

Spring Boot Flyway Migration

DodaTech 1 min read

In this tutorial, you'll learn about Fix Spring Boot Flyway Migration Not Running. We cover key concepts, practical examples, and best practices.

The Problem

Flyway migrations are not detected or fail on startup.

Quick Fix

Naming convention

Wrong:

V1__init.sql
// Lowercase v

Output:

Migration ignored

Right:

V1__init.sql -> V1__init.sql
V2__add_email.sql -> V2__add_email.sql

Output:

Correct prefix required: V, U, or R

Correct location

Wrong:

// Migrations in wrong folder

Output:

Not found

Right:

spring.flyway.locations=classpath:db/migration

Output:

Migrations found

Disable JPA DDL auto

Wrong:

spring.jpa.hibernate.ddl-auto=update
// Conflicts with Flyway

Output:

Schema conflicts

Right:

spring.jpa.hibernate.ddl-auto=none

Output:

No conflict with Flyway

Prevention

  • Use correct Flyway naming convention
  • Place migrations in db/migration directory
  • Disable spring.jpa.hibernate.ddl-auto when using Flyway

Common Mistakes with boot flyway migration

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world SPRING code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why are Flyway migrations not detected?

Use the naming convention V{version}__{description}.sql.

This quick fix is part of the DodaTech Spring & JVM ecosystem series. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro