Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

micronaut not creating table Flyway

I have a problem. I want the person table to be created when micronaut starts up. To do this, I use flyway, connected the dependency like this:

    //----Micronaut Data
    implementation("io.micronaut.data:micronaut-data-jdbc")
    implementation("io.micronaut.sql:micronaut-jdbc-hikari")
    implementation("io.micronaut.sql:micronaut-jooq")

    //---FlyWay and Postgresql
    runtimeOnly("org.postgresql:postgresql")
    implementation("io.micronaut.flyway:micronaut-flyway")
    runtimeOnly("org.flywaydb:flyway-core")

Further, in application.yml I wrote the configuration for Flyway. I will send the entire application yml file:

micronaut:
  application:
    name: demo7
  server:
    port: 9000
datasources:
  default:
    driver-class-name: org.postgresql.Driver
    db-type: postgres
    dialect: POSTGRES
    username: postgres
    url: jdbc:postgresql://localhost:5432/disa
    password: 1234

netty:
  default:
    allocator:
      max-order: 3
flyway:
  datasources:
    enabled: true
    url: jdbc:postgresql://localhost:5432/disa
    username: postgres
    password: 1234

When the application starts, no errors are thrown, but the table is not created either. My db.migration path looks like this:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Name of my SQL script: V1_1__create_all_tables.sql
Help me please.
My sql script:

CREATE TABLE person(
                       id   bigint primary key not null,
                       name varchar(255)       not null,
                       age  int                not null
)

>Solution :

Make sure you add the datasource name default to your Flyway configuration.

flyway:
  datasources:
    default:
      enabled: true

And you don’t need to copy the credentials and the connection string.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading