0

Good Morning everyone, I am creating a backend for my application and I want to migrate my database using Flayway.

I added the required dependancies to my pom.xml

                <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
            <version>10.15.0</version>
        </dependency>

I also configured my application.yml:


spring:
  datasource:
    username: speed
    url: jdbc:postgresql://localhost:5432/DBManage
    password: userpass66!
  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        format_sql: 'true'
    hibernate:
      ddl-auto: update
    show-sql: 'true'
  flyway:
    driverClassName: org.postgresql.Driver
    enabled: true
    baseline-on-migrate: true
    user: speed
    password: userpass66!
  

But after using the flyWay pulgin (I am using vscode by the way) I got this error:

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:10.20.1:migrate (default-cli) on project backend: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password! -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Can anyone advice me or tell me why I got this error since I created all the necessary migration files on the db\migration.

Thank you.

2
  • You have configured flyway for use with Spring Boot not for use with the Maven plugin. Commented Feb 7 at 10:32
  • @M.Deinum, I understand, but please can you tell me how to fix this please ? Commented Feb 7 at 10:44

1 Answer 1

0

So, I was able to migrate my database, but spring boot always use the "default" database and doesn't take database on my "DBManage" schemas.

    spring:
  
  datasource:
    username: speed
    url: jdbc:postgresql://localhost:5432/DBManage
    password: userpass66!
  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        format_sql: 'true'
    hibernate:
      ddl-auto: update
    show-sql: 'true'
  logging:
    level:
        org.flywaydb: DEBUG
        org.hibernate.SQL: DEBUG
        org.hibernate.type.descriptor.sql.BasicBinder: TRACE

  flyway:
    enabled: 'true'
    baseline-version: 0
    url: jdbc:postgresql://localhost:5432/DBManage
    user: speed
    password: userpass66!
    default-schema: DBManage
    locations: classpath:db/migration

but it takes only the default schema :

2025-02-08T14:21:13.071+01:00  INFO 18208 --- [  restartedMain] 

o.f.core.internal.command.DbValidate     : Successfully validated 3 migrations (execution time 00:00.241s)
2025-02-08T14:21:13.171+01:00  INFO 18208 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "DBManage": 1
2025-02-08T14:21:13.182+01:00  INFO 18208 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Schema "DBManage" is up to date. No migration necessary.
2025-02-08T14:21:13.293+01:00  INFO 18208 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2025-02-08T14:21:13.391+01:00  INFO 18208 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.6.5.Final
2025-02-08T14:21:13.439+01:00  INFO 18208 --- [  restartedMain] o.h.c.internal.RegionFactoryInitiator    : HHH000026: Second-level cache disabled
2025-02-08T14:21:13.815+01:00  INFO 18208 --- [  restartedMain] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2025-02-08T14:21:13.885+01:00  INFO 18208 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2025-02-08T14:21:13.962+01:00  INFO 18208 --- [  restartedMain] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@25

Can anyone tell me why please ?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.