How to fix "No migrations found. Are your locations set up correctly?" Flyway migration at MySQL?

522 Views Asked by At

I'm creating a project Java with Spring Boot 3, using:

  1. Flyway migration with a file: application.properties:
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345
  1. resources/db.migration/V1__create-table-doctor.sql
    create table doctors(
    id bigint not null auto_increment,
    name varchar(100) not null,
    email varchar(100) not null unique,
    crm varchar(6) not null unique,
    specialty varchar(100) not null,
    street varchar(100) not null,
    neighborhood varchar(100) not null,
    zipcode varchar(9) not null,
    complement varchar(100),
    number varchar(20),
    state char(2) not null,
    city varchar(100) not null,

    primary key(id)

 );
  1. When I run de api.application, the terminal ALWAYS shows me the message: enter image description here

  2. I tried to create too, another file to change the table "resources/db.migration/V2__alter-table-doctor.sql", but the issue persists, showing the same message at the terminal.

Observation:

  • I've tried to change the application.properties from:
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345

to:

    spring.datasource.url=jdbc:mysql://localhost:3306/vollmed_api
    spring.datasource.username=admin
    spring.datasource.password=12345

but the issue persists too.

  • I've tried to open my Workbench, drop and create database manually and it's working normally!

Please, could you help me?

Another question, I realized that I didn't get to run MySQL on my IntelliJ terminal: enter image description here I just got "so so" when I installed an extension DB Browser.

Create and change tables at MySQL using FLYWAY Migration from Spring Boot 3 (IntelliJ).

1

There are 1 best solutions below

0
Camila Alves On

I've changed the application.properties and included the configuration: "spring.flyway.locations=classpath:db/migration". But I didn't change the folder "db.migration". After that, I dropped my database, recreated it, and ran API. It's working now!